On my webpage, I have a login form that creates a session - but PHP doesn't seem to be acknowledging it:
require_once('globals.php');
require_once('header.php');
if(!isset($_SESSION) || session_id() == '')
{
$x = (isset($_SESSION));
var_dump($_SESSION['username']);
?><br><?PHP
var_dump(session_id());
?><br><?PHP
var_dump($x);
require_once('system/default.php');
}
else
{
require_once('system/' . $SystemScreens[$_SESSION['screen']]);
}
require_once('footer.php');
is producing:
NULL
string(0) ""
bool(false)
relavant part of login script (where $finalCheck
is a boolean stating if the login was successful)
if($finalCheck)
{
session_start();
$_SESSION['userID'] = $UserID;
$_SESSION['username'] = $username;
$_SESSION['accessLevel'] = $UserAccess;
$_SESSION['screen'] = 1;
}
else
{
if(session_id() != '' || isset($_SESSION))
{
if (ini_get("session.use_cookies"))
{
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
}
session_destroy();
}
}
I know that the login function is returning true
because I have visual confirmation (result is returned to an AJAX request, and the page reloaded if true - which it does)
I can't figure out why everything is running as if the login is successful, but the session isn't being recognised after the reload occurs?