note 129578 added to function.session-start
| From: | theking2(at)king.ma | Date: | Wed, 12 Jun 2024 18:53:37 +0000 |
| Subject: | note 129578 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221373@lists.php.net to get a copy of this message | ||
I generally use this to start a new session
<?php
session_start( [
'name' => DEBUG ? 'SessionId' : '__Secure-SessionId',
'cookie_lifetime' => 0,
'cookie_path' => '/',
'cookie_domain' => $_SERVER['HTTP_HOST'],
'cookie_secure' => true,
'cookie_httponly' => true,
'cookie_samesite' => 'Strict',
'sid_length' => 96,
'sid_bits_per_character' => 5,
'use_strict_mode' => true,
'referer_check' => $_SERVER['HTTP_HOST'],
] );
?>
which will create a session with increased entropy in the session cookie name, requires a secure
session, make sure roque referers have no chance at my logon page among other things.
According to MDN[1] prefix "__Secure-" must be set for secure sessions.
[1](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie)
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 185.159.157.11)
----
Manual Page -- https://php.net/manual/en/function.session-start.php
Edit -- https://main.php.net/note/edit/129578
Del: integrated -- https://main.php.net/note/delete/129578/integrated
Del: useless -- https://main.php.net/note/delete/129578/useless
Del: bad code -- https://main.php.net/note/delete/129578/bad+code
Del: spam -- https://main.php.net/note/delete/129578/spam
Del: non-english -- https://main.php.net/note/delete/129578/non-english
Del: in docs -- https://main.php.net/note/delete/129578/in+docs
Del: other reasons-- https://main.php.net/note/delete/129578
Reject -- https://main.php.net/note/reject/129578
Search -- https://main.php.net/manage/user-notes.php