I have looked around on Stack Overflow and many other sites for a solution to my problem but still no solution has come and I don't even get how my problem is even possible. The question is at the bottom of the post.
Here are the contents of login.php:
include("loginFunctions.php");
include("databaseFunctions.php");
if(checkSession())
{
header("location: adminArtist.php");
exit();
}
Here are the contents of loginFunctions.php:
function checkSession()
{
$isOnLine = false;
session_start();
if(isset($_SESSION["online"]))
{
$isOnLine = true;
session_regenerate_id(true);
}
else
{
endSession();
}
return $isOnLine;
}
Here are the contents of adminArtist.php:
include("loginFunctions.php");
if(!checkSession())
{
header("location: login.php");
exit();
}
Here's the problem I have: When I login I get to the adminArtist page, so that means $_SESSION["online"] = true
in both login.php and adminArtist.php. However, when I hit the submit button or press F5 or reload the page in any other way, it sends me back to login screen. This is probably because all of a sudden the $_SESSION["online"]
has become false.
What do I have to do to keep the value as true?
I was not sure how much code I needed to post, but I think this should be enough to locate what I have done wrong. Otherwise I will edit and add more.