I managed to get the query to update the database after 15 min of inactivity and log out the user. but when the user logs in and closes the browser, the only time they will be logged out is next time the go on the website. How can i do it so that even if they close the browser, the database still gets updated somehow?

```
// log out the user after 60 seconds of inactivity
    if (isset($_SESSION['timestamp'])) {
        $elapsed_time = time() - $_SESSION['timestamp'];
        if ($elapsed_time >= 900) {
            mysql_query("UPDATE `users` SET `status` = '0' WHERE `user_id` = '$session_user_id'");
            session_destroy();
            header('Location:index.php');
        }
    }
    $_SESSION['timestamp'] = time();

```

at this point, if the user logs in and closes the browser, they will appear logged in forever