Whenever the user login on my page the username
is stored as a $_SESSION
variable like so:
$_SESSION['username'] = $username;
where $username
is the email address of the user and further user is assumed to be logged in. What I have observed is that my user is automatically logged out instantly after logging in or after few times. Are my session variables lost or what other problem should be?
My session_start()
is always at the beginning and there is no space above it, so this is not the problem.
The part of my login code when login is successful is:
if ($usererror != 1 && $passworderror != 1 && $conferror != 1) {
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
header('Location:/dashboard_test/index.php');
}
The first page that accepts login has the first few lines as:
session_start();
$username = $_SESSION['username'];