note 36842 added to function.setcookie
| From: | mastabog hotmail | Date: | Fri, 24 Oct 2003 10:51:47 +0000 |
| Subject: | note 36842 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59216@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36842
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36842&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36842&report=yes
Search -- http://master.php.net/manage/user-notes.php