I'm trying to kill session after 30 seconds (testing) but it just doesn't work. I don't understand why. I've followed relevant topic here on SO and tried to implement suggested solutions but it didn't work so please don't give me crap about duplicates.
this is my code:
session_start();
$_SESSION['email'] = $email;
$userID = $row['userID'];
$_SESSION['userID'] = $userID;
$_SESSION['timeout'] = time();
and in session.php I've got:
if(isset($_SESSION['timeout']) && (time() - $_SESSION['timeout']) > 30) {
header("Location: loggedoutDisplay.php");
exit();
}
$_SESSION['timeout'] = time();
Providing more code:
if($result = mysqli_query($link,$query)) {
while($row = mysqli_fetch_assoc($result)) {
session_start();
$_SESSION['email'] = $email;
$userID = $row['userID'];
$_SESSION['userID'] = $userID;
$_SESSION['timeout'] = time();
header("Location: updatePage.php");
}
}
Here I'm starting session after user being successfully identified and redirected to updatePage.php
where I need to session to end after 30 seconds.