为 Chrome 77 上的 google recaptcha v2 警告尝试 SameSite 属性修复似乎对我不起作用?

Posted

技术标签:

【中文标题】为 Chrome 77 上的 google recaptcha v2 警告尝试 SameSite 属性修复似乎对我不起作用?【英文标题】:Trying the SameSite attribute fix for the google recaptcha v2 warning on Chrome 77 doesn't seem to be working for me? 【发布时间】:2020-02-08 05:32:52 【问题描述】:

如果我要重复这个问题,我深表歉意,但我已经在这个问题上花费了 6 多天,我正在失去理智。即使我已经仔细尝试并重试将这些警告添加到我的 php 索引中的 and 标记之前,我似乎也无法让该警告消失。我试过帖子 SameSite warning Chrome 77 使用

response.setHeader("Set-Cookie", "HttpOnly;Secure;SameSite=Strict");

以及这里的帖子 How to solve `SameSite` attribute 使用

header('Set-Cookie: cross-site-cookie=name; SameSite=None; Secure');

以及此处的示例 https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md

即使其他一切都没有改变,我仍然会收到警告。我错过了什么或做错了什么?抱歉,我想这应该没什么大不了的,但我对这些弹出的警告消息和错误非常着迷,我希望它们会消失!提前谢谢。

-update- 抱歉,有问题的控制台中弹出的警告是这样的

A cookie associated with a cross-site resource at http://google.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.

【问题讨论】:

有人吗?一定有人知道如何让这个警告消失...... 【参考方案1】:

该警告专门针对来自“google.com”的 cookie,因此您无法影响它。如果任何控制台警告涉及您控制的域,那么您应该按照该建议更新您的 SameSite 属性。

这确实意味着您将继续看到这些警告,直到受影响的域更新其 cookie,这应该会在未来几个月内发生。直到 Chrome 80 才计划执行此行为,Chrome 80 将在 2 月稳定。因此,在此之前,稳定的 Chrome 中不会影响任何实际的站点/服务功能。

【讨论】:

2021 年更新。它可能比这更复杂。 reCaptcha 3 在我的 Asp.Net Core 应用程序中生成来自 google.com 的 28 个“SameSite”cookie 警告,但相同的 reCaptcha 在托管在同一服务器上的 WordPress 站点中运行良好,根本没有任何警告。我还假设 Google 无疑正确地实施了他们的 cookie。

以上是关于为 Chrome 77 上的 google recaptcha v2 警告尝试 SameSite 属性修复似乎对我不起作用?的主要内容,如果未能解决你的问题,请参考以下文章