note 48637 added to function.setcookie
| From: | SijmenRuwhof at osu1 dot php dot net | Date: | Sun, 02 Jan 2005 20:41:02 +0000 |
| Subject: | note 48637 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82619@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48637
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48637&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48637&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48637&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48637&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48637&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48637&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48637&report=yes
Search -- http://master.php.net/manage/user-notes.php