Tomcat 7 - JSESSIONID cookie 无法从 JavaScript 代码访问

发布于 2024-12-20 23:12:46 字数 268 浏览 6 评论 0 原文

有谁知道 Tomcat 6 和 Tomcat 7 之间的配置发生了什么变化,导致无法通过 JavaScript 访问 JSESSIONID cookie?

使用 Tomcat 6:

alert(document.cookie); // JSESSIONID=8675309ABCDEF...

使用 Tomcat 7:

alert(document.cookie); // nothing

Does anyone know what changed in the configuration between Tomcat 6 and Tomcat 7 that would cause the JSESSIONID cookie to not be accessible via JavaScript?

Using Tomcat 6:

alert(document.cookie); // JSESSIONID=8675309ABCDEF...

Using Tomcat 7:

alert(document.cookie); // nothing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰葑 2024-12-27 23:12:46

好吧,我找到了答案。 Tomcat 6,并且在 true href="http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Common_Attributes" rel="noreferrer">Tomcat 7。该属性是为 容器设置的。

<Context useHttpOnly="false" [...] />

有关从 Tomcat 6 更新到 7 的更多信息:迁移自6.0.x 到 7.0.x

我不确定为什么我之前没有在文档中看到这一点,但我已经验证将其设置为 false实际上确实会导致 Tomcat 7 恢复为 Tomcat 6 行为。

Okay, I found the answer. The useHttpOnly attribute was set to false by default in Tomcat 6, and is true in Tomcat 7. This attribute is set for the <Context> container.

<Context useHttpOnly="false" [...] />

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文