note 125072 added to function.session-set-cookie-params

From: Date: Tue, 02 Jun 2020 14:53:13 +0000
Subject: note 125072 added to function.session-set-cookie-params
Groups: php.notes 
Request: Send a blank email to php-notes+get-214712@lists.php.net to get a copy of this message
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 ]); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.166.36 (proxied: 170.52.64.77) ---- Manual Page -- http://php.net/manual/en/function.session-set-cookie-params.php Edit -- https://master.php.net/note/edit/125072 Del: integrated -- https://master.php.net/note/delete/125072/integrated Del: useless -- https://master.php.net/note/delete/125072/useless Del: bad code -- https://master.php.net/note/delete/125072/bad+code Del: spam -- https://master.php.net/note/delete/125072/spam Del: non-english -- https://master.php.net/note/delete/125072/non-english Del: in docs -- https://master.php.net/note/delete/125072/in+docs Del: other reasons-- https://master.php.net/note/delete/125072 Reject -- https://master.php.net/note/reject/125072 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214712) next »