in reply to Re: Multiple Cookies with CGI::Application
in thread Multiple Cookies with CGI::Application
Well, yes, kinda. Cookies are name=value pairs, when you get down to it. But using CGI.pm, one doesn't really use them directly that way.
perldoc CGI says:
The interface to HTTP cookies is the cookie() method: $cookie = $query->cookie(-name=>'sessionID', -value=>'xyzzy', -expires=>'+1h', -path=>'/cgi-bin/database', -domain=>'.capricorn.org', -secure=>1); print $query->header(-cookie=>$cookie);
In the example, $cookie is actually a hashref, or more accurately, a CGI::Cookie object.
Now to pass multiple cookies, you use a ref to an anonymous array, containing the cookie objects you wish to pass. CGI.pm continues:
To create multiple cookies, give header() an array reference: $cookie1 = $query->cookie(-name=>'riddle_name', -value=>"The Sphynx's Questio +n"); $cookie2 = $query->cookie(-name=>'answers', -value=>\%answers); print $query->header(-cookie=>[$cookie1,$cookie2]);
Hope this clarifies things a little.
cheers!
In Section
Seekers of Perl Wisdom