|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-05-11 08:12 UTC] sas at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Jan 21 21:00:02 2026 UTC |
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