From 25edfc2663a0d87e6216981c44dadb52d1f8ab72 Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 12 Feb 2016 17:44:27 +0100 Subject: feature #383, dedicated function to delete sessions --- admin/include/functions.php | 6 +----- include/functions_session.inc.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/admin/include/functions.php b/admin/include/functions.php index b377fc7a6..04a83d0bc 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -405,11 +405,7 @@ DELETE FROM '.$table.' } // purge of sessions - $query = ' -DELETE FROM '.SESSIONS_TABLE.' - WHERE data LIKE \'%pwg_uid|i:'.(int)$user_id.';%\' -;'; - pwg_query($query); + delete_user_sessions($user_id); // destruction of the user $query = ' diff --git a/include/functions_session.inc.php b/include/functions_session.inc.php index 9c12e26c1..61a6acac9 100644 --- a/include/functions_session.inc.php +++ b/include/functions_session.inc.php @@ -260,4 +260,20 @@ function pwg_unset_session_var($var) return true; } +/** + * delete all sessions for a given user (certainly deleted) + * + * @since 2.8 + * @param int $user_id + * @return null + */ +function delete_user_sessions($user_id) +{ + $query = ' +DELETE + FROM '.SESSIONS_TABLE.' + WHERE data LIKE \'pwg_uid|i:'.(int)$user_id.';%\' +;'; + pwg_query($query); +} ?> -- cgit v1.2.3