How can the error message "A session had already been started - ignoring session_start()" impact the functionality of the "header Location" function in PHP?

When the error message "A session had already been started - ignoring session_start()" occurs, it means that a session has already been started before calling the session_start() function. This can impact the functionality of the "header Location" function in PHP because headers must be sent before any output is sent to the browser, including session_start(). To solve this issue, you can check if a session is already active before starting a new one.

<?php
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

// Your code here

header("Location: new_page.php");
exit;
?>