diff --git a/src/App/bootstrap.php b/src/App/bootstrap.php index 0551baa8..277990b5 100644 --- a/src/App/bootstrap.php +++ b/src/App/bootstrap.php @@ -27,7 +27,38 @@ if (!function_exists('desktop_configure_session_storage')) { } } +if (!function_exists('desktop_configure_session_cookie')) { + function desktop_configure_session_cookie(): void + { + if (session_status() === PHP_SESSION_ACTIVE) { + return; + } + + session_name('desktop_kusche_sid'); + + $isHttps = false; + if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { + $isHttps = true; + } + + $forwardedProto = trim((string) ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')); + if ($forwardedProto !== '') { + $isHttps = strtolower(trim(explode(',', $forwardedProto)[0] ?? '')) === 'https'; + } + + session_set_cookie_params([ + 'lifetime' => 0, + 'path' => '/', + 'domain' => '', + 'secure' => $isHttps, + 'httponly' => true, + 'samesite' => 'Lax', + ]); + } +} + desktop_configure_session_storage(); +desktop_configure_session_cookie(); spl_autoload_register(static function (string $class): void { $prefixes = [