note 35107 added to function.setcookie
| From: | erik_neves at hotmail dot com | Date: | Tue, 19 Aug 2003 22:31:52 +0000 |
| Subject: | note 35107 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54720@lists.php.net to get a copy of this message | ||
The manual states that "cookies will not become visible until the next loading of a page that
the cookie should be visible for", but there's a way around this that doesn't require
a refresh. Just set the $_COOKIE variable right after you setcookie().
$lang = 'pt-br';
setcookie('lang', $lang);
$_COOKIE['lang'] = $lang;
The reason for this is that $_COOKIE is automatically set only when the page loads, but setting it
explicitely makes the new cookie value available globally even for the same page that created it.
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35107
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35107&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35107&report=yes