I have everything working on my login except for the admin user.
When I try to navigate to my admin.php I get “Must be logged in” even if I am already logged in as an admin.
When I click the admin link, I first go to checkAdmin.php which is the code below.
<?php
if($_SESSION['userEmail'] != 'admin@hotmail.com') {
echo "<center><font face='Verdana' size='2' color=red>Must be logged in</font> <br><a href=index.php>Login Here</a></center>";
exit;
}
?>
Am I doing something wrong on this?
Thanks.
I have session_start(); at the top of my admin.php page.
I used print_r($_SESSION); and got this line, so it has the right value.
Array ( [userEmail] => admin@hotmail.com )
Also, if I add session_start(); to the checkAdmin.php then the screen just sits at checkAdmin, when I click to go to the admin page.
The admin.php has this at the top
session_start();
require "checkAdmin.php";
include("db_info.php");
Make sure you have called
session_start()before checking session variables.