Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute
Because a cookie’s SameSite attribute was not set or is invalid, it defaults to SameSite=Lax, which prevents the cookie from being sent in a cross-site request. This behavior protects user data from accidentally leaking to third parties and cross-site request forgery.
Resolve this issue by updating the attributes of the cookie:
Specify SameSite=None and Secure if the cookie should be sent in cross-site requests. This enables third-party use.
Specify SameSite=Strict or SameSite=Lax if the cookie should not be sent in cross-site requests
AFFECTED RESOURCES
5 cookies
Name Domain & Path
UM_distinctid .amap.com/
dev_help .amap.com/
isg .amap.com/
l .amap.com/
tfstk .amap.com/
2 requests
百度了一圈似乎是跨域问题,这些代码在TOMCAT服务器中运行正常,但是在HTML页面中单独运行则失败了。先挖一个坑:等调试完成来解决该问题。顺便了解一下常常被考到的面试题:跨域。
SameSite 属性
Cookie 的SameSite属性用来限制第三方 Cookie,从而减少安全风险。
它可以设置三个值。
- Strict
- Lax
- None
几种写法
Set-Cookie: CookieName=CookieValue; SameSite=Lax;
Set-Cookie: CookieName=CookieValue; SameSite=Lax;
注意这里的Secure
Set-Cookie: widget_session=abc123; SameSite=None; Secure
参考链接:https://blog.csdn.net/weixin_44269886/article/details/102459425?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param