【问题标题】:Internet explorer ignoring cookiesInternet Explorer 忽略 cookie
【发布时间】:2014-11-17 10:36:04
【问题描述】:

我读过类似的问题,但几乎所有这些问题都与双字母域下划线有关。不是我的情况。我正在使用 Intranet,所以关于域名没有问题。另外,如果我尝试使用域名而不是 IP(认为 IE 可能不信任我的 IP),问题仍然存在。

让我总结一些事实:

  • 没有两个字母的域名问题。
  • 没有下划线问题。
  • 在 Intranet 10.*(HTTP 和 HTTPS)中不工作,但在 172.* 和本地工作。
  • 不是防火墙问题。我已经在没有防火墙的情况下对其进行了测试,直接指向服务器(Tomcat 7.0.42)
  • 问题仅在于 IE(使用 IE7 到 IE11 测试)。使用 Chrome 和 Firefox。
  • 不是 cookie 路径问题。我已经使用“sessionCookiePath”强制 cookie 路径。见http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
  • 不是斜线问题。我已将“sessionCookiePathUsesTrailingSlash”设置为 false 和 true。
  • Tomcat 一直在发送响应头中的 cookie,但请求头中没有 cookie。
  • 即使我使用公共 URL 访问服务器也无法正常工作(带有威瑞信证书的 HTTPS URL)。
  • 我已将 IE 配置为接受 cookie 并将我的站点添加为受信任站点。
  • 我什至已经在 10. 服务器上下载了 tomcat 安装并在我的本地运行它。它有效。
  • 使用 Firefox,如果使用 firebug 配置为拒绝来自我的站点的 cookie,行为是相同的。服务器随时发送新的 cookie。

这里是请求头(我点击登录按钮):

Solicitar   POST /admin/j_spring_security_check HTTP/1.1
Accept  application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer https://10.45.17.2/admin/login
Accept-Language es-ES
User-Agent  Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Content-Type    application/x-www-form-urlencoded
Accept-Encoding gzip, deflate
Host    10.45.17.2
Content-Length  57
DNT 1
Connection  Keep-Alive
Cache-Control   no-cache

响应头

Respuesta   HTTP/1.0 302 Found
Date    Mon, 17 Nov 2014 10:21:18 GMT
Server  Apache
Set-Cookie  JSESSIONID=FA5205FEA416706667A0F309465AEA61.nodo2; Version=1; Path="/admin/"; Secure; HttpOnly
Location    https://10.45.17.2/admin/start
Content-Length  0
Connection  close
Content-Type    text/plain; charset=UTF-8   

用户已登录,但服务器应用程序再次将用户带到登录页面:

请求头:

Solicitar   POST /admin/j_spring_security_check HTTP/1.1
Accept  application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer https://10.45.17.2/admin/login
Accept-Language es-ES
User-Agent  Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Accept-Encoding gzip, deflate
Host    10.45.17.2
Connection  Keep-Alive
Cache-Control   no-cache
DNT 1
Solicitar   GET /admin/start HTTP/1.1
Accept  application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer https://10.45.17.2/admin/login
Accept-Language es-ES
User-Agent  Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Accept-Encoding gzip, deflate
Host    10.45.17.2
Connection  Keep-Alive
Cache-Control   no-cache
DNT 1

响应者阅读器:

Respuesta   HTTP/1.0 302 Found
Date    Mon, 17 Nov 2014 10:21:18 GMT
Server  Apache
Set-Cookie  JSESSIONID=2F868BF115F960E72E1F5ED0DDDD7B19.nodo1; Version=1; Path="/admin/"; Secure; HttpOnly
Location    https://10.45.17.2/admin/login
Content-Length  0
Connection  close
Content-Type    text/plain; charset=UTF-8   

您可以看到服务器如何发送不同的 cookie。所有请求都会发生这种情况。

另外,请注意我正在使用 Struts2 和 Spring Security。

有什么想法吗?提前致谢。

【问题讨论】:

    标签: internet-explorer cookies tomcat7


    【解决方案1】:

    终于,问题解决了。问题是会话路径中的双引号。将系统属性FWD_SLASH_IS_SEPARATOR 设置为 false 即可解决问题。

    -Dorg.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR=false

    一些文档:http://wiki.apache.org/tomcat/Cookies

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 2012-03-30
      • 2010-10-22
      • 2011-06-29
      • 1970-01-01
      • 2016-08-21
      相关资源
      最近更新 更多