同一个网站两次Request不同session问题排查记录

博客讨论了在HTTP服务中,由于不支持Secure属性导致的Cookie问题。当尝试从HTTP请求中设置Secure属性的Cookie时,浏览器会阻止该操作。这通常发生在先用HTTPS然后切换到HTTP访问同一域名的情况下。解决方法包括清除HTTPS域名下的Cookie信息。核心原因是Cookie不会根据端口进行隔离,因此在不同端口的服务间无法区分。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

现象:

        两次request的hashCode相同,但request.getSession()获取到的session却不同;

排查记录:

        其在 Chrome Devlope tools中 对应的提示:接口在 Response 响应头中Set-Cookie 时 失败。

This Set-Cookie was blocked because it was not sent over a secure-connection and would have overwritten a cookie with Secure attribute.

       

原因:

        1、 HTTP服务不支持Secure安全属性。Secure表示Cookie会以安全的形式传输,HTTP肯定是不满足的。

        2、历史使用了Https 访问过相同域名, 再以http访问且不设置Secure属性,也是不可以的。 解决办法: 清除https域名下cookie信息
根本原因: cookie不能通过 port 进行隔离。

Cookies do not provide isolation by port. If a cookie is readable by a service running on one port, the cookie is also readable by a service running on another port of the same server.

原文链接:https://www.jianshu.com/p/ecc498da117b

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值