Chrome浏览器跨域设置cookie失败的问题
电脑自动升级了 chrome 浏览器,导致本地访问 localhost 本地测试环境的时候,无法设置cookie,cookie 无法在header携带过去,导致获取用户信息失败,无法联调。
chorme header 头的 cookie 里有一个黄色的小叹号, 提示 This set-cookie didn't specify a 'SameSite' attribute and was defaulted to 'SameSite=lax' and broke the same rules specified in the SameSitelax value,samesite 是 chrome 为了限制第三方 cookie 问题而加的功能,对于 chrome 80 后的版本,跨域的时候,Lax 在大多数情况下不发送第三方 cookie。
解决方案
在chrome新标签页面访问
chrome://flags/#same-site-by-default-cookies
chrome://flags/#cookies-without-same-site-must-be-secure
分别把这两项设置为 Disabled,并重启浏览器。
共有 0 条评论