diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index d6e6d15e40d3e5ceb250ccc89d01f53c25cf7ea5..b81b58e45b1848cab8b61c26ecf0c5e0799d665e 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -91,10 +91,6 @@ class SessionHandlerPHP extends SessionHandler 'samesite' => $params['samesite'], ]); } else { - /* in older versions of PHP we need a nasty hack to set RFC6265bis SameSite attribute */ - if ($params['samesite'] !== null and !preg_match('/;\s+samesite/i', $params['path'])) { - $params['path'] .= '; SameSite=' . $params['samesite']; - } session_set_cookie_params( $params['lifetime'], $params['path'], @@ -322,6 +318,13 @@ class SessionHandlerPHP extends SessionHandler $ret['httponly'] = $config->getBoolean('session.phpsession.httponly', true); + if (version_compare(PHP_VERSION, '7.3.0', '<')) { + // in older versions of PHP we need a nasty hack to set RFC6265bis SameSite attribute + if ($ret['samesite'] !== null and !preg_match('/;\s+samesite/i', $ret['path'])) { + $ret['path'] .= '; SameSite=' . $ret['samesite']; + } + } + return $ret; }