note 36842 deleted from function.setcookie by tularis

From: Date: Sun, 02 Jan 2005 14:22:39 +0000
Subject: note 36842 deleted from function.setcookie by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82588@lists.php.net to get a copy of this message
Note Submitter: mastabog<a>hotmail<d>com ---- There was a post earlier saying that there is a workaround of the fact that cookies are only available after a refresh. For newcomers, cookies are ONLY available after you change the page that has set a cookie. In the new page you can see the cookie that was set accessing the $_COOKIE array. The workaround that guy proposed sothat you see the cookie in the same page where you set it was both to make a call to setcookie(), which sets the cookie into the browser for the pages to follow, AND to modify manually the $_COOKIE array. NEVER do that if you want to work with real cookies. Sure modifying the $_COOKIE array is possible (its just another global array variable from the language point of view) but if the cookie is not set then you will still have a value in your $_COOKIE array (cus you set it manually) but no real cookie in your browser, and on the pages to follow there won't be any cookie. Also its not a "nice" way of programming :) ... predefined global arrays usually should not be modified manually. Try to always avoid that "workaround". Use cookies properly like they were ment to. Cheers, Bogdan

« previous php.notes (#82588) next »