1//Ending a php session after 30 minutes of inactivity
2$minutesBeforeSessionExpire=30;
3if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > ($minutesBeforeSessionExpire*60))) {
4 session_unset(); // unset $_SESSION
5 session_destroy(); // destroy session data
6}
7$_SESSION['LAST_ACTIVITY'] = time(); // update last activity