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:
Then you see if the key you are looking for is there, we will use 'test' since this is a test:my %cookie = CGI::Cookie->fetch;
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()).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); }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |