First, please start learning how to search the site, as this questions has been asked many time: delete cookie. You can find answers to the immediate question at How can I delete a cookie?

Second, i gave you cookie code over at (jeffa) 7Re: CGI.pm error and (jeffa) 3Re: CGI.pm error many moons ago. Looks like you didn't understand any of it, so lets start over.

You first get any cookies that might be available:

my %cookie = CGI::Cookie->fetch;
Then you see if the key you are looking for is there, we will use 'test' since this is a test:
if (exists $cookie{test}) { # we have our cookie, do something with $cookie{test}->value } else { # we don't have a cookie, need to make one my $cookie = CGI::Cookie->new(-name=>'test',-value=>12345); # now we "inject" into the HTTP headers print header(-cookie=>$cookie); }
You do not print the HTTP header first without seeing if there are cookies or not. Once you print the HTTP header, game over. If you needed to do some cookie munging, you can't. You have to get the cookie first, modify whatever you need to, then "send if off" in the HTTP header (via print header()).

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: Problem to delete a cookie by jeffa
in thread Problem to delete a cookie by webstudioro

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.