Ignoring session_start() because a session is already active
PHP Programming Language
Severity: MinorWhat it means
PHP 8: Notice: session_start(): Ignoring session_start() because a session is already active. Newer versions add where it first started, such as (started from /var/www/header.php on line 2).
PHP 7: Notice: session_start(): A session had already been started - ignoring.
It's only a notice. The session that's already running carries on, and the second call does nothing.
Affected Models
- PHP 7 and PHP 8
How to Fix It
-
Look for session_start() in every file of the page, including files pulled in with include or require. Often a shared header file and the page itself both call it.
-
Call it once, near the top of the first file that runs.
-
Or guard it: if (session_status() === PHP_SESSION_NONE) { session_start(); }.
-
session.auto_start on in php.ini? Then PHP starts the session by itself, and the message says the session is already automatically active. Remove your session_start() calls, or turn auto_start off.