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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|