Perl cookie问题
我在perl上写了一个http会话管理器,会话管理器必须将cookie写入用户浏览器,当我在firefox 4上测试它时,它工作正常,并且cookie被写入浏览器,chrome和IE似乎拒绝某些cookie原因,我做了一次检查,但没有用,我的cookie显示如下:
Set-Cookie:session=nSwbgFp5suScOMjmDMVNxv4EQLJpDat7YanRJGfM3hrvbjCCprUvocU4HxiR4Tk_VUAV6hE68zlriRvX0CeC4Ytk1DJc8IhCn_4C;expires=Sat, 2011 年 5 月 14 日 10:10:56 GMT
我注意到了一些事情,如果我将 cookie 配置为 1 天后过期。它适用于所有浏览器,但一小时后就不适用于 IE 和 Chrome。 如果有人知道如何在 IE 或 Chrome 中嗅探 cookie,请告诉我。我的意思不是使用网络嗅探器。因为我确信 cookie 会发送到 browser 。我的意思是与浏览器有关的东西。
提前致谢。
my ($key, $value) = @_;
my (@cookies, $k, $v, $r, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
my @chars = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '_');
my @weekday = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
my @month = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$r = '';
foreach (1 .. 100) {$r .= $chars[rand @chars]}
## Calculate the expiration date of the session
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time() + $::session_life);
$year = $year + 1900;
$mon = $month[$mon];
$wday = $weekday[$wday];
## Generate cookies
print("Set-Cookie:$::session_cookie_name=$r;" . "expires=$wday, $mday-$mon-$year $hour:$min:$sec GMT;\n");
I wrote an http session manager on perl, the session manager has to write cookies to the user browser, when I test it on firefox 4, it works fine, and cookies are written to the browser, chrome and IE seem to reject cookies for some reason, I made an invistagation but no use, my cookies appear like this:
Set-Cookie:session=nSwbgFp5suScOMjmDMVNxv4EQLJpDat7YanRJGfM3hrvbjCCprUvocU4HxiR4Tk_VUAV6hE68zlriRvX0CeC4Ytk1DJc8IhCn_4C;expires=Sat, 14-May-2011 10:10:56 GMT
Something I noticed, if I configure the cookies to expire in 1 day. it work for all browser, but an hour it wont work for IE and chrome.
If anyone has an idea about how to sniff cookies in IE or chrome, let me know . I don't mean using a network sniffer. Since I'm sure that cookies are emitted to browser . What I mean that something related to browsers.
thanks in advance.
my ($key, $value) = @_;
my (@cookies, $k, $v, $r, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
my @chars = ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '_');
my @weekday = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
my @month = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$r = '';
foreach (1 .. 100) {$r .= $chars[rand @chars]}
## Calculate the expiration date of the session
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time() + $::session_life);
$year = $year + 1900;
$mon = $month[$mon];
$wday = $weekday[$wday];
## Generate cookies
print("Set-Cookie:$::session_cookie_name=$r;" . "expires=$wday, $mday-$mon-$year $hour:$min:$sec GMT;\n");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
时间计算错误。使用库 CGI::Cookie 生成符合标准的 cookie 标头。
The time calculation is wrong. Use the library CGI::Cookie to generate a standard conforming cookie header.