diff --git a/php/public/index.php b/php/public/index.php index fb4f6117dd0..49ee6ae1742 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -23,13 +23,6 @@ $container = \AIO\DependencyInjection::GetContainer(); $dataConst = $container->get(\AIO\Data\DataConst::class); -ini_set('session.save_path', $dataConst->GetSessionDirectory()); - -// Auto logout on browser close -ini_set('session.cookie_lifetime', '0'); - -# Keep session for 24h max -ini_set('session.gc_maxlifetime', '86400'); // Create app AppFactory::setContainer($container); @@ -44,7 +37,16 @@ }); // Register Middleware To Be Executed On All Routes -session_start(); +session_start([ + "save_path" => $dataConst->GetSessionDirectory(), // where to save the session files + "gc_maxlifetime" => 86400, // delete sessions after 24 hours ... // https://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime + "gc_probability" => 1, // ... to ... // https://www.php.net/manual/en/session.configuration.php#ini.session.gc-probability + "gc_divisor" => 1, // 100% // https://www.php.net/manual/en/session.configuration.php#ini.session.gc-divisor + "use_strict_mode" => true, // only allow initialized session IDs // https://www.php.net/manual/en/session.configuration.php#ini.session.use-strict-mode + "cookie_secure" => true, // only send cookies over https (not http) // https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#secure + "cookie_httponly" => true, // block the cookie from being read with js in the browser, will still be send for fetch request triggered by js // https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#httponly + "cookie_samesite" => "Strict", // only send the cookie with requests triggered by AIO itself // https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value +]); $app->add(Guard::class); // Create Twig