Fix SameSite cookie using PHP

Aneh Thakur
TrinityTuts
Published in
1 min readApr 14, 2020

Cookies are one of the methods available for adding persistent state to web sites. Over the years their capabilities have grown and evolved but left the platform with some problematic legacy issues. To address this, browsers (including Chrome, Firefox, and Edge) are changing their behavior to enforce more privacy-preserving defaults.

What is SameSite cookie?

Last year in May 2019, Chrome announced its plan to develop a secure model for handling cookies. Chrome promise to provide a more secure and fast browsing experience to its users. Chrome tries to increase more transparency and control to its users. Users should be aware of how they are tracked and who is tracking them. Today users are more concerned about their privacy and increase in potential cross-site attacks chrome is taking action to protect its users.

Fix SameSite cookie using PHP

<?php
session_start();
header('Set-Cookie: ' . session_name() . '=' . session_id() . '; SameSite=None; Secure');

You can read the complete post here:- Fix SameSite cookie in chrome

--

--