How to solve `SameSite` attribute

前端 未结 3 1654
面向向阳花
面向向阳花 2021-01-04 02:29

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 a

相关标签:
3条回答
  • 2021-01-04 03:00

    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

    0 讨论(0)
  • 2021-01-04 03:10

    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

    0 讨论(0)
  • 2021-01-04 03:11

    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:

    0 讨论(0)
提交回复
热议问题