diff --git a/core/functions/session_proxy.php b/core/functions/session_proxy.php index 67434c8139..14b16d9a53 100644 --- a/core/functions/session_proxy.php +++ b/core/functions/session_proxy.php @@ -57,7 +57,10 @@ public static function init(): void self::migrateLegacySessionIfNeeded($store); // Start PHP session with cookies disabled (Laravel owns the cookie). - if (session_status() === PHP_SESSION_NONE) { + // Skipped on CLI: there are no headers to send there, and the merge + // below fills $_SESSION either way. The CLI installer reaches this + // after it has printed, so each call would only warn. + if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_NONE) { ini_set('session.use_cookies', '0'); if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) { ini_set('session.use_only_cookies', '0'); diff --git a/index.php b/index.php index 7a9ec39ecd..acf3a7f105 100644 --- a/index.php +++ b/index.php @@ -82,7 +82,9 @@ if (IN_INSTALL_MODE) { // Set some settings, and address some IE issues. @ini_set('url_rewriter.tags', ''); - if (session_status() === PHP_SESSION_NONE) { + // Browser-only session tweaks. The CLI installer includes this file after + // it has already printed, so on CLI these only warn about sent headers. + if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_NONE) { ini_set('session.use_trans_sid', 0); ini_set('session.use_only_cookies', 1); }