note 47786 added to function.setcookie
| From: | jamesatmiicrodotnet at osu1 dot php dot net | Date: | Tue, 30 Nov 2004 11:07:31 +0000 |
| Subject: | note 47786 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81174@lists.php.net to get a copy of this message | ||
With regard to refreshing a page after 0 seconds in order to allow the browser to 'see'
the cookie immediately (posted by brewthatistrue at plzYnoAspamHorOevilO dot com)...
It works, but bear in mind that if the user presses their Back button they will be sent back to the
same page (or if it's called from the same page, it will constantly reload). With such a short
time delay, they will probably be caught in a loop.
It's maybe better to write a function that sets the cookie to a variable which will be
accessible to the web page immediately, then the cookie will take effect on any future visits to the
page.
ie. something like
if($_POST["foo"]) {
$bar = $_POST["foo"];
} else {
$bar = $_COOKIE["foo"];
}
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47786
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47786&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47786&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47786&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47786&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47786&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47786&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47786&report=yes
Search -- http://master.php.net/manage/user-notes.php