|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-09-27 13:46 UTC] cheatah at tweakers dot net
When using the setcookie function, I noted that setting the value to NULL had the following result:
The expire time argument was completely ignored, and automatically set to one year and one second ago. Also the value sent to the browser for this cookie had changed to 'deleted'.
I browsed the PHP source code, and saw my suspicions confirmed, this is the correct behaviour.
Could this be included in the documentation? I really like the following syntax:
setcookie('name', null, null, '/');
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 05:00:01 2025 UTC |
yes, it's the same problem trouble me. then same when setcookie('name', '', 0, '/'); the question is: Is 1 year and 1 second enough ? when a pc lost battery, and turned off, system clock is reset to long long ago. i dunno if a browser compare the "Expire time" to system clock or "Date: ..." header return by server the document of php tell us nothing about this. currently, i have to do: setcookie('name', "0", 0, '/'); and change my script isset($_COOKIE['name']) to !empty($_COOKIE['name']) even javascript: var myc = mygetcookie('name'); if (myc && myc != '0') { //....... } hope there's a final solution to this problem :)