I need to logout a specific user programmatically whose uid is known to me.
I think I need to destroy the session. Is there any table in drupal store that value?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI need to logout a specific user programmatically whose uid is known to me.
I think I need to destroy the session. Is there any table in drupal store that value?
Use drupal_session_destroy_uid function.
Ends a specific user's session(s).
Example:
drupal_session_destroy_uid($uid_to_logout);
You can condition in this code to logout user
// Programmatically logs out the current user
global $user;
$tmp = NULL;
session_destroy();
user_module_invoke('logout', $tmp, $user);
$user = drupal_anonymous_user(); //or any user you get from database