Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Setting several values and Reading them from a cookie

by blokhead (Monsignor)
on Sep 22, 2002 at 04:48 UTC ( [id://199849]=note: print w/replies, xml ) Need Help??


in reply to Setting several values and Reading them from a cookie

You can pass an array ref (or even a hash ref) to the -value parameter of CGI::Cookie::new. From the CGI::Cookie documentation:
Create cookies from scratch with the new method. The -name and -value parameters are required. The name must be a scalar value. The value can be a scalar, an array reference, or a hash reference. (At some point in the future cookies will support one of the Perl object serialization protocols for full generality).
So you can set multiple values by doing
my $cookie = new CGI::Cookie( -name => 'ChocolateChip', -value => [ 'Sweet', 'Semi-Sweet', 'Yumm +y' ] );
If there are multiple values for a cookie, the $cookie->value method will return a list of them (only if it's called in list context, of course).

blokhead

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found