Possible Duplicate:
timed auto logout and browser close
i am storing the user usage of a website in a mysql table and i am able to capture and store the login time using a insert query at the time of login-in and i am capturing the logout time also if the user choose to logout via logout button.
but what if the user just closes the browser then how can i fire the query for the logout time.
what i got till now is this, but with this i can address the session timeout issue but not the "browser close"
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800))
{
// last request was more than 30 minates ago
session_unset(); // unset $_SESSION variable for the runtime
session_destroy(); // destroy session data in storage
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
please help me to solve this out..