Im having trouble destroying my session on a little test-side that i made.
I can log in from my code_login.php file, and header() to my other page, where login is required. But when i log out, sometimes can go back to that page even though i logged out.
(session_start() is at the top of all my pages)
This is my login code:
$res = $db->query($sql);
$num = $res->num_rows;
if ($num == 1) {
$_SESSION['user'] = array(
'username' => $username;
);
}
Here is the logout:
session_start();
$_SESSION = array();
session_destroy();
header('LOCATION: index.php?loggedOut');
This is the top of my page where login is required
session_start();
if (isset($_SESSION['user'])) {
require some stuff;
} else {
header('LOCATION: index.php?loginNeeded');
}
But still sometimes i am able to go back to the loginrequired page, after logging in.