function userIsLoggedIn(){
if(isset($_POST['action']) and $_POST['action'] == 'login'){
if (!isset($_POST['email']) or $_POST['email'] == '' or !isset($_POST['password']) or $_POST['password'] == ''){
echo 'Please fill in both fields';
return FALSE;
exit();
}
if (databaseContainsAuthor($_POST['email'], $_POST['password']) and userAccountIsActive($_POST['email'])){
if(!isset($_SESSION)){session_start();};
$_SESSION['loggedIn'] = TRUE;
$_SESSION['email'] = $_POST['email'];
$_SESSION['password'] = $_POST['password'];
echo 'Please Wait, Redirecting...';
exit();
}
else{
if(!isset($_SESSION)){session_start();};
unset($_SESSION['loggedIn']);
unset($_SESSION['email']);
unset($_SESSION['password']);
echo 'The specified email address or password was incorrect.';
exit();
}
}
if (isset($_POST['action']) and $_POST['action']=='logout'){
session_start();
unset($_SESSION['loggedIn']);
unset($_SESSION['email']);
unset($_SESSION['password']);
header('Location: .');
exit();
}
if(!isset($_SESSION)){session_start();};
if (isset($_SESSION['loggedIn'])){
return databaseContainsAuthor($_SESSION['email'], $_SESSION['password']);
}
}
include $_SERVER['DOCUMENT_ROOT'] . '/templates/header.html.php';
if(userIsLoggedIn()){
include $_SERVER['DOCUMENT_ROOT'] . '/templates/favourite-box.html.php';
};
You can see that i am not using return false or true for userIsLoggedIn() function nevertheless the template favourite box in including when i am loggedIn and it is not including when i am logged out.
Why it is working perfectly?