如何解决`SameSite`属性 [英] How to solve `SameSite` attribute
问题描述
我看着控制台,发现了这些警告
I looked at the console and noticed these warnings
在没有SameSite的情况下,设置了与 http://google.com/上的跨站点资源关联的cookie.属性.如果将来的Chrome浏览器版本设置了SameSite = None和Secure,则仅会发送带有跨站点请求的cookie.您可以在应用程序">存储">"Cookies"下的开发人员工具中查看Cookie,并在 https://www.chromestatus中查看更多详细信息. .com/feature/5088147346030592 和 https://www.chromestatus.com/feature/5633521622188032 .
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.
如何解决?
推荐答案
对我有用的解决方案:
如果您使用的是PHP,将此行添加到开头
header('Set-Cookie: cross-site-cookie=name; SameSite=None; Secure');
更新 这是有用的资源,包括JavaScript,Node.js,PHP和Python中的示例
https://github.com/GoogleChromeLabs/samesite-examples
Update Here is a useful resource including examples in JavaScript, Node.js, PHP, and Python
https://github.com/GoogleChromeLabs/samesite-examples
这篇关于如何解决`SameSite`属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!