note 49200 deleted from function.setcookie by tularis
| From: | tularis@php.net | Date: | Thu, 20 Jan 2005 09:41:00 +0000 |
| Subject: | note 49200 deleted from function.setcookie by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-83654@lists.php.net to get a copy of this message | ||
Note Submitter: RobVaughn at REMOVE dot gmail dot com
----
Found an interesting "feature" with Firefox 1.0 and setting cookies. We tested it with IE,
and Win2K and XP Pro, and it's definitely Firefox. If you have a script set a cookie without
setting a path, it uses the path that the script is stored in, for example if you set a cookie in a
script called:
/accts/login.php
Then the cookie path is "/accts" when you examine the cookie that's set. If you try
to "unset" a cookie with the standard format from a script that isn't in the same
path, for example:
/inc/logout.php
Then the following code WILL unset a cookie under IE but NOT Firefox 1.0:
<? set_cookie ("COOKIE", "", time() -3600); ?>
The problem is that COOKIE was set with a path of "/accts" but the logout.php code has a
path of "/inc" so under Firefox it doesn't match (whereas IE doesn't check.)
The following will work:
<? set_cookie ("COOKIE", "", time() -3600, "/accts"); ?>
Basically, in Firefox, if you can't remove cookies, be sure to check the domain and path
attributes of the cookies that are set, and if need be, specify them in the code where you try to
remove those cookies. Took a couple of hours to figure this out. Cheers!