On my site, the login.php page (if successful login) will redirect to index.php and will start a session and 2 SESSION variables.
One of the variables started is a success message:
$_SESSION["message"] = "Login successful!";
the second is the user session variable:
$_SESSION["authenticatedUserEmail"] = $email;
the problem is that if I check the variables individually and then try and use them on the index.php page, only the first one that is checked will work.
This following snippet will show the $form_message but it will not show the $_SESSION["authenticatedUserEmail"]:
session_start();
if(isset($_SESSION["message"])) {
$form_message = $_SESSION["message"];
session_unset($_SESSION["message"]);
echo $form_message;
} else {
$form_message = "";
}
if (isset($_SESSION["authenticatedUserEmail"])) {
echo $_SESSION["authenticatedUserEmail"];
}
It does work when I only use one if(isset($_SESSION statement but I don't want to always include both inside the same statement.
I've done an error check:
ini_set('display_errors',1);
error_reporting(E_ALL);
but no errors appear.
Can anyone please suggest why this may not be working or if I am missing something?
Thanks in advance.