What I want is to be able to delete session data without page refresh. So let's say my user created a session and left his computer on sleep mode for two years, I want to delete his session after 4800s... How can I do that?
At the moment, I have a code which only deletеs session on refresh only.
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 4800)) {
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
Or does this code work without page refresh? If not, how can constantly update this code?