Hello. I have this php code that I am using to redirect users to index.html once the logout link is pressed but it’s not working.
Logout link in the navbar.
<li><a href="logout.php"> Logout </a></li>
Logout:
<?php
session_start();
session_unset();
session_destroy();
header('Location:index.html');
?>
Also I have this session check on every page, and this redirecting is working:
<?php
session_start();
if (isset($_SESSION['session_user_first_name']))
{
if( isset($_SESSION[‘last_acted_on’]) && (time() - $_SESSION[‘last_acted_on’] > 60*5) )
{
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
header('Location: index.html');
}
else
{
session_regenerate_id(true);
$_SESSION[‘last_acted_on’] = time();
include("header.html");
include("menu.html");
require_once ('database_initialisation.php');
}
?>
Any suggestions?