note 65650 added to function.setcookie
| From: | matt at mattsoft dot net | Date: | Fri, 05 May 2006 00:47:59 +0000 |
| Subject: | note 65650 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-110592@lists.php.net to get a copy of this message | ||
using time()-1 to delete (expire) a cookie only works if the client's clock is set exact. my
testing showed some weird results with my clock set 1 second or so behind the server. 1 day or even
just a few seconds ahead of the server's time and the cookie doesn't expire when it's
suposed to.
my test:
setcookie('k',$k+1,time()-1);
echo $k;
setting the expire time to 0 makes it a browser session cookie, lasting forever, until the browser
is closed. but setting the expire time to 1 is the lowest timestamp possible and is most likely to
expire the cookie without any problems.
my fix:
setcookie('k',$k+1,1);
echo $k;
this is my theory. I'm not sure why no one else has thought of this problem or solution, and
I'm still testing, but please email me your questions or comments.
----
Server IP: 216.194.113.175
Probable Submitter: 24.115.146.152
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- http://master.php.net/note/edit/65650
Del: integrated -- http://master.php.net/note/delete/65650/integrated
Del: useless -- http://master.php.net/note/delete/65650/useless
Del: bad code -- http://master.php.net/note/delete/65650/bad+code
Del: spam -- http://master.php.net/note/delete/65650/spam
Del: non-english -- http://master.php.net/note/delete/65650/non-english
Del: in docs -- http://master.php.net/note/delete/65650/in+docs
Del: other reasons-- http://master.php.net/note/delete/65650
Reject -- http://master.php.net/note/reject/65650
Search -- http://master.php.net/manage/user-notes.php