note 17139 added to function.setcookie

From: Date: Tue, 27 Nov 2001 18:21:35 +0000
Subject: note 17139 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-21340@lists.php.net to get a copy of this message
After months of not even realizing it ... if you do a : setcookie ("mycookie", "myvalue", "time()+3600"); that should technically set a cookie for an hour right? WRONG!!! And ... if you do a : setcookie ("mycookie", "myvalue", time()+3600); that should definitely not work as others have tried it and it craps out and wont even set the cookie ... so what's the solution? well , for all your cookie issues to be solved, whether you're using an array, or just a basically storage method, and you actually WANT the cookie to last as long as you define it for (btw ... you should note, that if you do any of the above declarations, you are infact setting an uplink session to the browser ONLY ... the cookie will work, but is not accessible from other windows, and will immediately die if you close the window you created it from ... ), then you should just do the following ... god for sakes :) $mytime = time()+3600 // or whatever you want ... setcookie ("mycookie", $val, $mytime); and it will work marvelously ... ARG!!! I spent so long figuring that out :) hope that helps you all -- http://www.php.net/manual/en/function.setcookie.php http://master.php.net/manage/user-notes.php?action=edit+17139 http://master.php.net/manage/user-notes.php?action=delete+17139 http://master.php.net/manage/user-notes.php?action=reject+17139

« previous php.notes (#21340) next »