How can the error "A session had already been started - ignoring session_start()" be resolved in PHP?

The error "A session had already been started - ignoring session_start()" occurs when the session_start() function is called after a session has already been started. To resolve this error, you can check if a session is already active before calling session_start(). This can be done by using the session_status() function to check if the session has already been started.

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}