Bug #1347 Updated: setcookie executes after previous cookie value is read

From: Date: Sat, 24 Apr 1999 07:08:37 +0000
Subject: Bug #1347 Updated: setcookie executes after previous cookie value is read
Groups: php.dev 
Request: Send a blank email to php-dev+get-5245@lists.php.net to get a copy of this message
ID: 1347 User Update by: jwillis@pmz.com Status: Open Bug Type: Misbehaving function Description: setcookie executes after previous cookie value is read Php seems to be reading the previous cookie value before setting the cookie. So reading the cookie being currently set is quite impossible since it is the last thing done before the header is sent. Here is the snippet code. with two consecutive runs of the script. cookie and sessionid should be the same value. <?php $cookie = microtime(); SetCookie("BIN",$cookie,0,"/"); $sessionid = $BIN; echo "cookie = ".$cookie."<BR>"; echo "sessionid = ".$sessionid; exit; ?> cookie = 230.42169300 924936609 sessionid = 65.21762600 924936436 cookie = 245.03266400 924936625 sessionid = 230.42169300 924936609 As you can see the cookie being read by the $sessionid = $BIN; call is the current cookie before the new cookie gets set even though it is after the setcookie statement. The docs specifically mention that the contents of a cookie can be displayed after being set but this is not the case in the above code. Just as a comparision when I do the exact same thing with .asp the following occurs <% cookie = CDbl(Now()) Response.Cookies("BIN").path = "/" Response.Cookies("BIN") = cookie sessionid = Request.Cookies("BIN") %> cookie = <%= cookie %><BR> sessionid = <%= sessionid %> cookie = 36274.0025694444 sessionid = 36274.0025694444 Full Bug description available at: http://bugs.php.net?id=1347 -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5245) next »