Reputation: 444
i have a problem with setting and getting cookie data.
When i call following method:
%cookies = CGI::Cookie->fetch;
And print out the hash using Data::Dumper:
print Dumper(%cookies);
My Cookie that was created before with:
$sessioncookie = CGI::Cookie->new(-name=>'SID', -value=>"$sid", -expires=>'+1M', -path=>'/member/');
print $cgi->header(-cookie=>$sessioncookie);
Does not show up in the output. But it shows up in my browsers cookie list! All values are set and it seems like a normal cookie. But actually it can't be.
Does someone know what i am doing wrong. Is there a strict order for retrieving cookie data?
I also tried it with the method cgi.pm provides, but it didnt work either.
Please help me!
Upvotes: 0
Views: 1288
Reputation: 9075
As per the help on 'path' in CGI::Cookie
path
If you provide a cookie path attribute, the browser will check it against your script's URL before returning the cookie. For example, if you specify the path "/cgi-bin", then the cookie will be returned to each of the scripts "/cgi-bin/tally.pl", "/cgi-bin/order.pl", and "/cgi-bin/customer_service/complain.pl", but not to the script "/cgi-private/site_admin.pl". By default, the path is set to "/", so that all scripts at your site will receive the cookie.
So I would remove the path for the moment and retry.
As always with perl, if you aren't using strict and warnings then turn them on
Upvotes: 1