First: Change your -domain line to:
-domain => '.blahblah.com'
You need at least two periods in the domain line (to make sure you don't try to set a domain-wide cookie across a top level domain like .com or something).
Second: I prefer to use
CGI::Cookie. I've never had a problem with it.
SET COOKIE
use CGI::Cookie;
my $c = new CGI::Cookie(
-name => 'COOKIENAME',
-value => 'Whosyerdaddy',
-expires => '+1M',
-domain => '.domain.com'
);
print "Set-Cookie: $c\n";
READ COOKIES
my %temp = parse CGI::Cookie($ENV{HTTP_COOKIE});
my %cookies;
foreach (keys %temp) {
$cookies{$_} = shift @{$temp{$_}{value}};
}
I'm not sure why
parse returns an array of values for each cookie, but it does.
Yes, I could have used map, but I haven't had my coffee yet this morning. :)
TOSS YOUR COOKIES
print header();
my $debug = 1;
# READ COOKIE CODE
if ($debug) {
foreach (keys %cookies) {
print "$_: $cookies{$_}<BR>\n";
}
}
Redirect to a simple little script that runs this code. That should tell you how well your cookies worked.
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.