note 48637 deleted from function.setcookie by danbrown

From: Date: Sun, 17 May 2009 18:01:31 +0000
Subject: note 48637 deleted from function.setcookie by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155052@lists.php.net to get a copy of this message
Note Submitter: Sijmen Ruwhof ---- My experience with setting cookies, a must read for every developer that doenst want to spend his time debugging cookies.. - if your're using windows XP with Internet Explorer, having a local webserver running and you're setting a cookie in you script, don't set the domain name! Use false instead. Windows XP in combination with Internet Explorer (with Firefox your cookie will be set successful) will not set a cookie when the domain name points to localhost. Examples: <? setcookie('test', 'value', false, '/', 'localhost', 0); // wil not work in WinXP with IE, but will work in WinXP with Firefox ?> Someone noted already this bug in WinXP + IE, but said that the domainname should have a dot in it. That is totally untrue (i've tried a domainname with a dot in it that points to 127.0.0.1). I think that the problem persist that the domainname may not be pointing to 127.0.0.1 so the solution would be: <?php setcookie('test', 'value', false, '/', false, 0); // works ?> - be sure that the 4th argument (path) always ends with a slash '/' - be sure that the expire time is false or a timestamp, 0 is not the value for a session cookie (false is the value). -- Sijmen Ruwhof

« previous php.notes (#155052) next »