PDA

View Full Version : Can't Delete Cookies With CGI In Firefox


netroact
07-21-2008, 04:09 AM
I have a link that executes a script that deletes a cookie:


<a href="http://somesite.com/cgi-bin/somedir/delete_item.pl?item=blah">Delete</a>


It works just fine in IE, but as usual, it doesn't in Firefox.

Here's the delete script:


#!/usr/bin/perl
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$query = new CGI;
$cookiename = $query->url_param('item');
my $cookie = $query->cookie (
-name => $cookiename,
-value => '',
-path => '/',
-expires => '-1d');
print $query->header(-cookie=>$cookie,
-location=>'http://somesite.com');


Any ideas what Firefox wants?

netroact
07-21-2008, 04:33 AM
I might add that I know the problem's with the script, because I can remove the permissions and it hangs on the script.

KevinADC
07-21-2008, 06:17 AM
Was the cookie set from the same site?

netroact
07-21-2008, 12:31 PM
Yes. It's from the same site.

FishMonger
07-21-2008, 06:58 PM
You can't delete cookies from the users system. You can only add/change them.

Are you saying that the value and expiration aren't being updated?

How and when are you checking the status of the cookie?

netroact
07-22-2008, 12:06 AM
You can't delete cookies from the users system. You can only add/change them.

Are you saying that the value and expiration aren't being updated?

How and when are you checking the status of the cookie?

Yes, I think that's what I am trying to say. I overwrite the cookie with an expired cookie. I am checking the status after the redirect. The redirect takes me back to the page that displays the cookie. When I do this in IE it is gone. When I use Firefox it is still there.
I tested it different ways like printing to the browser, instead of the redirect. When I run a view cookies script, it is still there.

netroact
06-28-2009, 07:25 AM
I forgot to post the solution to this problem. When I attempted to overwrite the cookie with an expired cookie, I did not list the attributes in the expired cookie in the same order as the cookie I originally created. I changed the expired cookie to the same order as the original cookie, and now it works just fine.