ibanix has asked for the wisdom of the Perl Monks concerning the following question:
Hi fellow monks,
I've got a CGI app in development. I'm trying to set a cookie, and then immediately read from it. I don't seem to have any problems setting the cookie, but I can't seem to read right back from it. Code looks something like this:
Am I doing something wrong, or can't you create and read a cookie in the same pageview?
Thanks~!
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
I've got a CGI app in development. I'm trying to set a cookie, and then immediately read from it. I don't seem to have any problems setting the cookie, but I can't seem to read right back from it. Code looks something like this:
If I put debug info in, I can see that the cookie is being created, but not read; on the next refresh or call of the script the cookie is read.$new_cookie = cookie_creator_sub() if (some condition); .... if ($new_cookie) { print $q->header(-cookie=>$new_cookie); } else { print $q->header(); } my %cookie = $q->cookie('info'); .... sub cookie_creator_sub { ..... my %cookie_info = ( 'tempfile' => $tempfile, 'timestamp' => $timestamp, ); $newcookie = $q->cookie(-name=>'info', -value=>\%cookie_info, ); return $newcookie; }
Am I doing something wrong, or can't you create and read a cookie in the same pageview?
Thanks~!
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: reading and writing a CGI cookie in the same page
by VSarkiss (Monsignor) on Feb 21, 2003 at 02:02 UTC | |
Re: reading and writing a CGI cookie in the same page
by shotgunefx (Parson) on Feb 21, 2003 at 02:07 UTC | |
Re: reading and writing a CGI cookie in the same page
by dws (Chancellor) on Feb 21, 2003 at 02:52 UTC | |
Re: reading and writing a CGI cookie in the same page
by Cabrion (Friar) on Feb 21, 2003 at 02:08 UTC | |
by PodMaster (Abbot) on Feb 21, 2003 at 02:20 UTC |
Back to
Seekers of Perl Wisdom