#33627 [Opn->Bgs]: Setcookie problems

From: Date: Sun, 10 Jul 2005 07:03:30 +0000
Subject: #33627 [Opn->Bgs]: Setcookie problems
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81626@lists.php.net to get a copy of this message
ID: 33627 Updated by: tony2001@php.net Reported By: weathermon at optusnet dot com dot au -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: Linux 2.4.18-3smp #1 PHP Version: 4.3.11 New Comment: Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. Previous Comments: ------------------------------------------------------------------------ [2005-07-10 05:35:18] weathermon at optusnet dot com dot au 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 this bug report at http://bugs.php.net/?id=33627&edit=1

« previous php.bugs (#81626) next »