Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Multiple Cookies with CGI::Application

by acarvalh (Novice)
on Jul 28, 2002 at 02:09 UTC ( #185794=note: print w/replies, xml ) Need Help??

in reply to Multiple Cookies with CGI::Application

Your problem lies in the basic fact that cookies are unique value pairs. You would need to pass in a scalar value rather than an array (either $c1 or $c2 or $c3 or the three concatenated together.

Hope this helps. :-)
  • Comment on Re: Multiple Cookies with CGI::Application

Replies are listed 'Best First'.
Re: Re: Multiple Cookies with CGI::Application
by sedhed (Scribe) on Jul 28, 2002 at 03:16 UTC

    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://185794]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2022-06-29 12:23 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (96 votes). Check out past polls.