I know that basically the page redirects to a page that redirects to the first page, but for some reason I can't seem to find the errors in my code. Basically if the session is not logged in, go to the login page / do nothing, but if they are logged in redirect them to the index.
if (isset($_SESSION['loggedin'])) {
if ($_SESSION['loggedin'] == null || $_SESSION['loggedin'] == "false") {
$_SESSION['loggedin'] == "false";
}
elseif ($_SESSION['loggedin'] == "true") {
header('location:index.php');
}
}
CodePudding user response:
You can simply do it like this :)
This is your "index.php" in your system login page:
<?php
session_start();
if(isset($_SESSION['loggedin'])){
header("location:your_dashboard.php"); //your main dashboard
}
?>
And this is "your_dashboard.php" in your system:
<?php
session_start();
if(!isset($_SESSION['loggedin'])){
header("location: index.php"); //index of your login page
}
?>