From cf2a82fe8578bd10187157bd884b3f109f0b5201 Mon Sep 17 00:00:00 2001 From: Loui Chang Date: Thu, 13 Nov 2008 15:18:48 -0500 Subject: Clear out old expired sessions on log out. Signed-off-by: Loui Chang --- web/lib/acctfuncs.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'web/lib') diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc index 73db2708..d0b6b0ac 100644 --- a/web/lib/acctfuncs.inc +++ b/web/lib/acctfuncs.inc @@ -625,7 +625,6 @@ function try_login() { $num_tries = 0; # Account looks good. Generate a SID and store it. - # $dbh = db_connect(); while (!$logged_in && $num_tries < 5) { @@ -790,4 +789,15 @@ function user_is_privileged( $id ) } -?> +# Clear out old expired sessions. +function clear_expired_sessions($dbh) { + global $LOGIN_TIMEOUT; + + if (empty($dbh)) + $dbh = db_connect(); + + $q = "DELETE FROM Sessions WHERE LastUpdateTS < (UNIX_TIMESTAMP() - $LOGIN_TIMEOUT)"; + db_query($q, $dbh); + + return; +} -- cgit v1.2.3-24-g4f1b