How to solve `SameSite` attribute

2020-07-06 06:58发布

I looked at the console and noticed these warnings

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.

How to solve it?

标签: php html
3条回答
欢心
2楼-- · 2020-07-06 07:20

Does your .htaccess file contain a header unset cookie code? and you use cdn and its cache like cloudflare.

If so, just delete the code in the htaccess

查看更多
迷人小祖宗
3楼-- · 2020-07-06 07:27

There's nothing you can do until Google's developers/admins (and developers/admins of other external resources) modify their scripts/servers to include the necessary cookies settings to the cookies they generate when your website includes them. See here more more info:

https://github.com/GoogleChromeLabs/samesite-examples/issues/4#issuecomment-548598318

If you are debugging your website, you can temporarily ignore those entries in Chrome's developer tools console by adding this filter to the filter box:

-SameSite=None

For example:

Example of -SameSite=None filter in Chrome's developer tools console

查看更多
forever°为你锁心
4楼-- · 2020-07-06 07:34

A solution that worked for me:

If you are using PHP, add this line to the beginning

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


Update Here is a useful resource including examples in JavaScript, Node.js, PHP, and Python
https://github.com/GoogleChromeLabs/samesite-examples

查看更多
登录 后发表回答