in reply to Re^3: Can a cookie created via CGI.pm be deleted by CGI::SESSION?
in thread Can a cookie created via CGI.pm be deleted by CGI::SESSION?
You can do something like this though:
And then if you want to remove a cookie named 'foo':# # Temporarily pretends a cookie does not exist by modifying # the HTTP_COOKIE env variable. # sub rm_cookie { my ($cgi,$name) = @_; my $raw = $cgi->raw_cookie; # Obtain a list of all cookies (they are ; separated) # But exclude the one with the name you specify my @cookies = grep {!/^$name=/} split /; ?/, $raw; # Replace the HTTP_COOKIE env variable with the new fake # set of cookies. This is important, you might not want to # hide all cookies - just this one. $ENV{HTTP_COOKIE} = join('; ',@cookies); }
But keep in mind this is making perl pretend that there isn't a cookie by that name. You still need to remove the actual cookie (if this is your intent), using something similar to the parent post. Off to sleep - really this time.rm_cookie($cgi, 'foo');
|
|---|