搜索已经发现了几十个近似重复的问题,但通常人们会遇到完全相反的问题! (firefox很好,IE有问题)
这是我要求设置cookie的实用程序子:
sub setcookie { my $name = shift; my $value = shift; my $expires = shift; my $path = shift; my $domain = shift; if( !defined( $expires ) ) { $expires = '+4h'; } if( !defined( $path ) ) { $path = '/'; } if( !defined( $domain ) ) { $domain = 'steveperkins.sourceforge.net'; } my $cookie = CGI::cookie( -name => $name,-value => $value,-domain => $domain,-expIEs => $expires,-path => $path ); $r->header_out('Set-cookie' => $cookie);}
有任何想法吗?我的第一个想法是某种子域问题,因为我的SourceForge项目URL中有一个子域,而“localhost”没有.我已经尝试将cookie域设置为我的特定子域,或者只是基础“sourceforge.net”.它似乎没有任何区别.
更新:以下评论中的某人询问了http响应标头.我使用网络流量分析工具Wireshark来监控IE和firefox的请求和响应标头,这是它们的样子:
IE(作品)
请求
GET http://myproject.sourceforge.net/cgi-bin/myscript.cgi?page=user&userID=1 http/1.1Accept: image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/x-ms-application,application/vnd.ms-xpsdocument,application/xaml+xml,application/x-ms-xbap,application/vnd.ms-excel,application/vnd.ms-powerpoint,application/msword,application/x-shockwave-flash,*/*Referer: http://myproject.sourceforge.net/cgi-bin/myscript.cgiAccept-Language: en-usUA-cpu: x86Accept-EnCoding: gzip,deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 7.0; windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.30729; InfoPath.1; .NET CLR 3.0.30618)Proxy-Connection: Keep-AliveHost: myproject.sourceforge.netAuthorization: Basic [password omitted]
响应
http/1.1 200 OKServer: Nginx/0.7.63Date: Tue,26 Oct 2010 18:23:49 GMTContent-Type: text/HTML; charset=ISO-8859-1Expires: Thu,28 Oct 2010 18:23:49 GMTCache-Control: max-age=172800,proxy-revalIDatetransfer-encoding: chunkedProxy-Connection: Keep-AliveConnection: Keep-Alivecontent-encoding: gzipSet-cookie: USER=1; domain=myproject.sourceforge.net; path=/
firefox(不起作用)
请求
GET http://myproject.sourceforge.net/cgi-bin/myscript.cgi http/1.1Host: myproject.sourceforge.netUser-Agent: Mozilla/5.0 (windows; U; windows NT 6.0; en-US; rv:1.9.2.11) Gecko/20101012 firefox/3.6.11Accept: text/HTML,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-us,en;q=0.5Accept-EnCoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 115Proxy-Connection: keep-alivecookie: __utma=191645736.1501259260.1287701281.1288028150.1288100562.10; __utmz=191645736.1288101011.10.10.utmcsr=Google|utmccn=(organic)|utmcmd=organic|utmctr=sourceforge%20project%20web%20space%20basic%20auth; _JsuID=4215309712123065236Authorization: Basic [password omitted]
响应
http/1.1 200 OKServer: Nginx/0.7.63Date: Tue,26 Oct 2010 18:17:58 GMTContent-Type: text/HTML; charset=ISO-8859-1Expires: Thu,28 Oct 2010 18:17:58 GMTCache-Control: max-age=172800,proxy-revalIDatetransfer-encoding: chunkedProxy-Connection: Keep-AliveConnection: Keep-Alivecontent-encoding: gzipAge: 0解决方法 我会说你在设置过期时遇到了一个错误
if( !defined( $path ) ) { $expires = '/';}
应该
if( !defined( $path ) ) { $path = '/';}
更新:根据您在上面使用wireshark提供的信息,我会检查当firefox进入时是否实际调用了setcookie.(两个URL都是不同的btw,它可能表示代码中的逻辑跳过了基于的setcookie调用URL).还尝试在两个浏览器中使用相同的URL,看看会发生什么.
总结以上是内存溢出为你收集整理的为什么Perl的CGI :: cookie能够在IE中设置cookie,而不是Firefox?全部内容,希望文章能够帮你解决为什么Perl的CGI :: cookie能够在IE中设置cookie,而不是Firefox?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)