Php – How to solve `SameSite` attribute

htmlPHP

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?

Best Answer

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