Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Re: Multiple Cookies with CGI::Application

by sedhed (Scribe)
on Jul 28, 2002 at 03:16 UTC ( #185801=note: print w/replies, xml ) Need Help??

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, 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=>'', -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. 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.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://185801]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-05-24 21:55 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (84 votes). Check out past polls.