Im creating a session in the index which is where the login process happens, i then save "username, IsAdmin, logged, first_name,last_name" to the session.
session_start();
$_SESSION["logged"] = FALSE;
$logged = TRUE;
$_SESSION["username"] = $username;
$_SESSION["IsAdmin"] = $IsAdmin;
$_SESSION["logged"] = $logged;
$_SESSION["first_name"] = $first_name;
$_SESSION["last_name"] = $last_name;
header("Location:home.php");
If the user is logged in i want to display the homepage which it does, but it always displays the page even if the user isn't logged in.
When i change the if statement to false the page hides properly, so it must be the value of it.
But all the other variables get passed along the session fine.
<?php
Include('../connect.php');
session_start();
$IsAdmin = FALSE;
$logged = FALSE;
$username = "";
$username = $_SESSION["username"];
$IsAdmin = $_SESSION["IsAdmin"];
$logged = $_SESSION["logged"];
$first_name = $_SESSION["first_name"];
$last_name = $_SESSION["last_name"];
?>
<?php if(logged == TRUE) :?>
<?php Include('../navigation.php'); ?>
//CODE TO SHOW WHEN LOGGED INA
<?php Include('../footer.php'); ?>
</body>
</html>
<?php endif; ?>
I had to get rid of a load of html due to indentation problem apparently.