浏览器控制台警告 A cookie associated with a cross-site resource at <URL> was set without the `SameSite` attribute

描述

浏览器控制台警告 A cookie associated with a cross-site resource at was set without the SameSite attribute

参见Chrome Platform Statusstackoverflow - SameSite warning Chrome 77

简述一下,chrome 自 76 版起给 cookie 加了一个属性叫 SameSite,用于防止 CSRF 攻击。

此属性用于限制第三方的 cookie,拥有三个值

  • Strict。完全禁止第三方 Cookie,跨域时,任何情况下都不会发送第三方 Cookie。
Set-Cookie: CookieName=CookieValue; SameSite=Strict;
  • Lax。默认。多数情况不发送第三方 Cookie,但是导航到目标网址的 Get 请求除外
Set-Cookie: CookieName=CookieValue; SameSite=Lax;

导航到目标网址的 Get 请求只包括三种情况:

<a href="..."></a>

<link rel="prerender" href="..."/>

<form method="GET" action="...">
  • None。
Set-Cookie: widget_session=abc123; SameSite=None; Secure

默认是 Lax,并且第三方如百度设置服务器时也不带这个 SameSite 的配置,所以暂时无解,我们也无法做什么。可以说这是 Chrome 在推行新的标准而做的努力,总之期待一下第三方的站点后续的改进吧。

原文地址:https://www.cnblogs.com/everlose/p/13261433.html