How can I read multiple cookies with Perl's CGI.pm? <p>I am using CGI.pm to write out cookies. Now during the course of the user using my site, other cookies are added to the "test.com" cookie set, (as shown in the broswer history)</p> <p>But now I want to log the user out, and "clean" the PC. Since I don't know what scripts the user has used, I can't foresee what cookies would be on the PC.</p> <p>In short, it there a way to read all the cookies for "test.com" back into a script so I can then print them out again with a 1s duration, (effectively 'deleting' them) ** I know you can read the cookie back in with $xyz=cookie('$name') ... but how can I create the array holding the $name variable so I can loop through it? The script will also run on "test.com", so the cross site policy is not an issue</p> <p>+++++ <a href="http://stackoverflow.com/users/2766176/brian-d-foy">brian d foy</a> added a partial answer below. So this how I envisage the code might be strung together.</p> <pre><code>use CGI::Cookie; %cookies = CGI::Cookie-&gt;fetch; for (keys %cookies) { $del_cookie.="cookie(-NAME=&gt;'$cookies[$_]',-PATH=&gt;'/',-EXPIRES=&gt;'+1s');"; } print header(-cookie=&gt;[$del_cookie]); </code></pre> <p>I wondered how the script would recognise the domain. Appears the script is intelligent enough to only load the cookies for the domain for which the script is being executed on. (Now I've just got to find out why Firefox doesn't delete expired cookies!! Just found some listed that expired 29th - 31st Jan within my test domain, and at first wondered why they didn't appear in my cookie list!)</p>