I recently read "RFC 6265" on the attribute "Same Site", I looked at some articles that talked about that in April 2016, "same-site" attribute has been implemented for Chrome 51 and Opera 39 ...
I wonder if current PHP supports creating cookies with this attribute?
Reference:
- Feature documentation on Chrome’s
chromestatus.com
- HTTPbis draft first adopted by Chrome
- Latest HTTPbis draft
[Important update: As @caw pointed out below, this hack WILL BREAK in PHP 7.3. Stop using it now to save yourself from unpleasant surprises! Or at least wrap it in a PHP version check like
if (PHP_VERSION_ID < 70300) { ... } else { ... }
.]It seems like you can abuse the "path" or "domain" parameter of PHP's "setcookie" function to sneak in the SameSite attribute because PHP does not escape semicolons:
Then PHP sends the following HTTP header:
I've just discovered this a few minutes ago, so please do your own testing! I'm using PHP 7.1.11.