How can I read multiple cookies with Perl's CGI.pm? -
i using cgi.pm write out cookies. during course of user using site, other cookies added "test.com" cookie set, (as shown in broswer history)
but want log user out, , "clean" pc. since don't know scripts user has used, can't foresee cookies on pc.
in short, there way read cookies "test.com" script can print them out again 1s duration, (effectively 'deleting' them) ** know can read cookie in $xyz=cookie('$name') ... how can create array holding $name variable can loop through it? script run on "test.com", cross site policy not issue
+++++ brian d foy added partial answer below. how envisage code might strung together.
use cgi::cookie; %cookies = cgi::cookie->fetch; (keys %cookies) { $del_cookie.="cookie(-name=>'$cookies[$_]',-path=>'/',-expires=>'+1s');"; } print header(-cookie=>[$del_cookie]);
i wondered how script recognise domain. appears script intelligent enough load cookies domain script being executed on. (now i've got find out why firefox doesn't delete expired cookies!! found listed expired 29th - 31st jan within test domain, , @ first wondered why didn't appear in cookie list!)
if trying cgi script, you'll have access cookies domain. can list , reset them giving them time in past.
it sounds aren't asking cookie question @ all. you're asking how make array. cgi::cookies (which comes cgi.pm) has example deal cookies have access under domain:
%cookies = cgi::cookie->fetch; (keys %cookies) { do_something($cookies{$_}); }
Comments
Post a Comment