I have created 3 files.
The first one is my index.php file where all of my HTML is stored
// index.php file
<?php
session_start();
?>
<?php
if (!isset($_SESSION['u_id'])) {
header("Location: login.php");
exit();
}
?>
The second one is my login file (part of this) where i create sessions
//login.php
$_SESSION['u_id'] = $row['user_id'];
$_SESSION['u_first'] = $row['user_first'];
$_SESSION['u_last'] = $row['user_last'];
$_SESSION['u_email'] = $row['user_email'];
$_SESSION['u_log'] = $row['user_login'];
header("Location: ../index.php?login=success");
exit();
And the last one is for logout where i try to destroy my sessions
//logout.php
<?php
if (isset($_POST['submit'])) {
session_start();
session_unset();
session_destroy();
header("Location: ../login.php?logout");
exit();
}
So the problem is next... as you can see from the code, i check in my index.php file, if section is not set, to redirect users to login.php. After successfully login and logout, i try to visit the home page 'index.php' i expected browser to redirect me to login.php but it didn't happen, i see just white screen without html code when i inspect, there are also none errors in console.