https://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes

if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
session_unset();
session_destroy();
}
$_SESSION['LAST_ACTIVITY'] = time();