Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: CGI::cookie query

by wardk (Deacon)
on Apr 02, 2001 at 21:44 UTC ( [id://69073]=note: print w/replies, xml ) Need Help??


in reply to CGI::cookie query

so how about this...

#!/bin/perl use CGI qw/:standard/; use CGI::Cookie; use strict; my @cookie; # do this in a loop.... $cookie[0] = new CGI::Cookie(-name=>'ID',-value=>123456); $cookie[1] = new CGI::Cookie(-name=>'preferences', -value=>{ font => 'Helvetica', size => '12' }); print header(-cookie=>\@cookie);
which produces....
Set-Cookie: ID=123456 Set-Cookie: preferences=size&12&font&Helvetica Date: Mon, 02 Apr 2001 17:42:01 GMT Content-Type: text/html

Replies are listed 'Best First'.
Re: Re: CGI::cookie query
by Anonymous Monk on Apr 03, 2001 at 15:17 UTC
    Ive tried your script aswell. This is what im doing but it just wont put them all in the cookie. $inputs is a hash which contains only 9 instances (not over 4k).
    sub set_cookie_value { my ($inputs) = @_; my @cookies = (); my $key; foreach $key (keys %$inputs) { $cookie = new CGI::Cookie(-name=>$key, -value=>$inputs->{$key} +, -expires=>$inputs->{$key}, -path=>'/', -domain=>'', -secure=>0); push (@cookies, $cookie); } print header( -cookie=>\@cookies ); print "--$inputs->{'postcode'}--" }
    Any further ideas?

      what is the programs output?

      you can determine this by running it from a command line, CGI.pm will prompt you for some input variables (you can also pass them on the command line), like so: (line 1 is executing the script, 2 is the script prompting me for input, 3 is my input. between lines 3 and 4 I hit Ctrl-D, lines 4-7 is the output. in this case 2 cookies.

      1 xdev$ perl cook.pl 2 (offline mode: enter name=value pairs on standard input) 3 foo=bar 4 Set-Cookie: ID=123456 5 Set-Cookie: preferences=size&12&font&Helvetica 6 Date: Tue, 03 Apr 2001 21:01:04 GMT 7 Content-Type: text/html xdev$

      note the code executed above is the same code posted in the previous node

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-29 09:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found