CGI :: Cookie提取找不到cookie [英] CGI::Cookie fetch does not find cookie
问题描述
我在设置和获取Cookie数据时遇到问题。
i have a problem with setting and getting cookie data.
当我调用以下方法时:
%cookies = CGI::Cookie->fetch;
并使用Data :: Dumper打印出哈希:
And print out the hash using Data::Dumper:
print Dumper(%cookies);
我之前使用以下方法创建的Cookie:
My Cookie that was created before with:
$sessioncookie = CGI::Cookie->new(-name=>'SID', -value=>"$sid", -expires=>'+1M', -path=>'/member/');
print $cgi->header(-cookie=>$sessioncookie);
不显示在输出中。但是它显示在我的浏览器cookie列表中!
所有值都已设置,好像是一个正常的cookie。但实际上不可能。
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?
我也使用cgi.pm提供的方法尝试了此操作,但还是没有用。
I also tried it with the method cgi.pm provides, but it didnt work either.
请帮助我!
推荐答案
-
路径
path
如果提供cookie路径属性,浏览器将根据
脚本的URL对其进行检查在返回cookie之前。例如,如果您指定
路径 / cgi-bin,则cookie将返回到每个脚本
/cgi-bin/tally.pl, / cgi-bin /order.pl和
/cgi-bin/customer_service/complain.pl,但不包括脚本
/cgi-private/site_admin.pl。默认情况下,该路径设置为 /,以便您站点上的所有
脚本都将接收该cookie。
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.
与perl一样,如果您不使用严格警告,则将其打开
As always with perl, if you aren't using strict and warnings then turn them on
这篇关于CGI :: Cookie提取找不到cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!