Tomcat 7 - JSESSIONID cookie 无法从 JavaScript 代码访问
有谁知道 Tomcat 6 和 Tomcat 7 之间的配置发生了什么变化,导致无法通过 JavaScript 访问 JSESSIONID cookie?
使用 Tomcat 6:
alert(document.cookie); // JSESSIONID=8675309ABCDEF...
使用 Tomcat 7:
alert(document.cookie); // nothing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我找到了答案。 Tomcat 6,并且在 true href="http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Common_Attributes" rel="noreferrer">Tomcat 7。该属性是为
容器设置的。有关从 Tomcat 6 更新到 7 的更多信息:迁移自6.0.x 到 7.0.x
我不确定为什么我之前没有在文档中看到这一点,但我已经验证将其设置为
false
实际上确实会导致 Tomcat 7 恢复为 Tomcat 6 行为。Okay, I found the answer. The
useHttpOnly
attribute was set tofalse
by default in Tomcat 6, and istrue
in Tomcat 7. This attribute is set for the<Context>
container.For more information about updating from Tomcat 6 to 7: Migrating from 6.0.x to 7.0.x
I'm not sure why I didn't see that in the docs before, but I've verified that setting this to
false
does in fact cause Tomcat 7 to revert to the Tomcat 6 behavior.