in reply to Re^2: Cookies write to screen, not to cookie file
in thread Cookies write to screen, not to cookie file
Uh...try this?
common.cgi
#!/usr/bin/perl #################################### use CGI qw/:standard/; use CGI::Cookie; sub write_cookie { my $c = new CGI::Cookie(-name => 'foo', -value => ['bar','baz'], -expires => '+3M' ); print header(-cookie=>[$c]); %cookies = fetch CGI::Cookie; ## This is very bad. You should check that $cookies{'ID'} exists ## or your script will die when you run this code. # $id = $cookies{'ID'}->value; ## You've already filled %cookies with the cookies. Why ## do it again? # %cookies = parse CGI::Cookie($ENV{COOKIE}); } 1;
script.pl
#!/usr/bin/perl require "common.cgi"; write_cookie(); print "Something";
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Cookies write to screen, not to cookie file
by TJD (Initiate) on Jul 01, 2004 at 22:42 UTC | |
by antirice (Priest) on Jul 02, 2004 at 04:04 UTC |