in reply to Cookie not being set...
Unless you specify that you want a persistent cookie, there is no reason why the browser should save it to the filesystem. A session cookie could (should?) be kept entirely in memory.
The script diplays in the browser fine, but still no cookie is created.