Voting

: nine minus zero?
(Example: nine)

The Note You're Voting On

frank at frankforte dot ca
5 years ago
The following appears to work for setting the SameSite attribute on session cookies for PHP < 7.3.

<?php

$secure
= true; // if you only want to receive the cookie over HTTPS
$httponly = true; // prevent JavaScript access to session cookie
$samesite = 'lax';

if(
PHP_VERSION_ID < 70300) {
session_set_cookie_params($maxlifetime, '/; samesite='.$samesite, $_SERVER['HTTP_HOST'], $secure, $httponly);
} else {
session_set_cookie_params([
'lifetime' => $maxlifetime,
'path' => '/',
'domain' => $_SERVER['HTTP_HOST'],
'secure' => $secure,
'httponly' => $httponly,
'samesite' => $samesite
]);
}
?>

<< Back to user notes page

To Top