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:
$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;
}
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.
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;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.