http://www.perlmonks.org?node_id=18718

draco_iii has asked for the wisdom of the Perl Monks concerning the following question: (cgi programming)

How can I delete a cookie?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How can I delete a cookie?
by Ovid (Cardinal) on Jun 18, 2000 at 22:28 UTC
    See How can I maintain a session cookie for more information.

    If you don't set an expiration date on a cookie that you've created, it will be deleted when the browser is closed.

    If the user wants to delete a cookie created in a previous session, you can set the expiration date of the cookie in the past (or possibly set it to "", I haven't tried this).

    If you'd like to learn more, you can read Netscape's Preliminary Specification for cookies.

Re: How can I delete a cookie?
by cbraga (Pilgrim) on Jun 19, 2000 at 02:19 UTC
    To delete a cookie, send the cookie again, with a null (empty string) value. The expiration date won't matter.

    Originally posted as a Categorized Answer.

Re: How can I delete a cookie?
by Anonymous Monk on Jan 09, 2004 at 18:24 UTC
    set the expire date to a date that is before the date of your set cookie.

    Originally posted as a Categorized Answer.

Re: How can I delete a cookie?
by Toxa (Novice) on Dec 16, 2004 at 15:15 UTC

    Use "expires" or you can send the cookie again with a null value "";

    Ex:

    use CGI qw/:standard/; use CGI::Cookie; my %CookieVars = ( ISAUTH => $ActualCookieVars{ISAUTH}, USERNAME => $ActualCookieVars{USERNAME}, AUTHLEVEL => $ActualCookieVars{AUTHLEVEL}, MYNUMBER => "$mynumber" ); # set cookie to the user my $cookie1 = new CGI::Cookie( -name=>'Test', -value =>\%CookieVars, # var to be sent -expires=>'+1h', # time to expire -domain=>"teste.com", # domain -path=>'/', #option path -secure=>0 # no ssl );
Re: How can I delete a cookie?
by Anonymous Monk on Apr 22, 2004 at 04:49 UTC
    srg

    Originally posted as a Categorized Answer.

Re: How can I delete a cookie?
by Anonymous Monk on Apr 22, 2004 at 04:49 UTC
    srg

    Originally posted as a Categorized Answer.

Re: How can I delete a cookie?
by Anonymous Monk on Apr 22, 2004 at 04:49 UTC
    srg

    Originally posted as a Categorized Answer.