Cookie Problem in Firefox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mtairhead
Forum Newbie
Posts: 2
Joined: Fri Aug 03, 2007 4:08 pm

Cookie Problem in Firefox

Post by mtairhead »

I've been having a PHP problem, and I guess it warrants a question for the Gurus.

I have found that I can easily set a cookie:

Code: Select all

setcookie("cookiename", "", exptime);
No problem. I cannot, however, seem to get my cookie to be UNset. I only have this problem when I use Firefox. Internet Explorer sets unsets cookies like a dream, however cookies set in Firefox won't go away until they've expired, and it's driving me crazy.

I've attempted all of the following methods:

Code: Select all

setcookie("emailAddress", "", time()-86400);
setcookie("emailAddress", "", time()-9999999999999999999999999999999999999999999999999); //(Exaggeration)
session_destroy();
setcookie("emailAddress" ,"",0,"/");
Thanks for any insight.

~Andrew
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Firefox will only unset the cookie if it matches the precise combination of name, path, domain and security level, if memory serves.
mtairhead
Forum Newbie
Posts: 2
Joined: Fri Aug 03, 2007 4:08 pm

Post by mtairhead »

Yep...Thanks, feyd

About the delete part, I found that Firefox only remove the cookie when you submit the same values for all parameters, except the date, which sould be in the past. Submiting blank values didn't work for me.

Example :
- set -
setcookie( "name", "value", "future_timestamp", "path", "domain" );

- delete -
setcookie( "name", "value", "past_timestamp", "path", "domain" );

Jonathan
http://us2.php.net/setcookie

~Andrew[/url][/quote]
Post Reply