|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-10 09:03 UTC] tony2001@php.net
[2005-07-12 12:17 UTC] weathermon at optusnet dot com dot au
[2005-07-12 12:22 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 21:00:02 2026 UTC |
Description: ------------ The submit bug report doesn't have my PHP version in there, I am using 4.3.2. When I use setcookie, it seems to only be setting the cookie every 2nd time I load the page for some reason. I am getting the value from $_GET and storing that in the cookie. Just for debugging purposes, I am printing the thumbview parameter and the cookie value each time it's run. Basically I want the cookie to be set to the thumbview's value each time I change it. I have no idea why it gets set only when I refresh the page a second time. Reproduce code: --------------- <?php if ($_GET["thumbview"]!="") { $sdata = $_GET["thumbview"]; if (!setcookie ("dirlisting", $sdata, time()+3600)) { print ("cookie NOT set!"); } else { print ("cookie set!"); } } print "<br>Thumbview: ".$sdata; print "<br>Cookie Value: ".$_COOKIE["dirlisting"]; ?> Expected result: ---------------- test.php?thumbview=0 cookie set! Thumbview: 0 Cookie Value: 0 test.php?thumbview=1 cookie set! Thumbview: 1 Cookie Value: 1 Actual result: -------------- test.php?thumbview=0 cookie set! Thumbview: 0 Cookie Value: 0 test.php?thumbview=1 cookie set! Thumbview: 1 Cookie Value: 0 I refresh the page again and this time it sets the cookie: test.php?thumbview=1 cookie set! Thumbview: 1 Cookie Value: 1