#33627 [NEW]: Setcookie problems

From: Date: Sun, 10 Jul 2005 03:35:19 +0000
Subject: #33627 [NEW]: Setcookie problems
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81625@lists.php.net to get a copy of this message
From: weathermon at optusnet dot com dot au Operating system: Linux 2.4.18-3smp #1 PHP version: 4.3.11 PHP Bug Type: *General Issues Bug description: Setcookie problems 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 -- Edit bug report at http://bugs.php.net/?id=33627&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33627&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33627&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33627&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33627&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33627&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33627&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33627&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33627&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33627&r=support Expected behavior: http://bugs.php.net/fix.php?id=33627&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33627&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33627&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33627&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33627&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33627&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33627&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33627&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33627&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33627&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33627&r=mysqlcfg

« previous php.bugs (#81625) next »