我知道关于 cookie 的行为从 chrome 80 改变了。
https://blog.chromium.org/2019/10/developers-get-ready-for-new.html
该博客说,“当存在 SameSite=None 属性时,必须使用额外的 Secure 属性,以便只能通过 HTTPS 连接访问跨站点 cookie。”
这是否意味着 SameSite=None 和 Secure=False 的 cookie 将被 Chrome 拒绝?我们不能设置这样的cookie吗?
我不能那样读。
但是,在本博客所写的测试方式中也表明,
描述说“它将被拒绝”。
Cookies without SameSite must be secure
If enabled, cookies without SameSite restrictions must also be Secure. If a cookie without SameSite restrictions is set without the Secure attribute, it will be rejected. This flag only has an effect if "SameSite by default cookies" is also enabled. – Mac, Windows, Linux, Chrome OS, Android
这是正确的行为吗?
最佳答案
正确的。如果您正在设置 SameSite=None
它必须永远是Secure
.如果不设置 Secure
,cookie 将被拒绝。
Chrome 为早期测试提供了两个标志:
chrome://flags/#same-site-by-default-cookies
- 此标志将处理没有 SameSite
的 cookie属性好像他们有 SameSite=Lax
. chrome://flags/#cookies-without-same-site-must-be-secure
- 此标志将导致带有 SameSite=None
的 cookie但不见了 Secure
被拒绝。 虽然从 Chrome 实现的角度来看,这是两个单独的更改,但开发人员应该将其视为一项更改。查看现有 cookie 并设置适当的
SameSite
和 Secure
可能的属性。
关于google-chrome - 是否不会从 Chrome 80 设置 samesite=none 和 secure=true 的 cookie?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60593771/