function _autologout_invalidate_other_sessions in Automated Logout 6.2
Same name and namespace in other branches
- 7.2 autologout.module \_autologout_invalidate_other_sessions()
1 call to _autologout_invalidate_other_sessions()
- autologout_user in ./autologout.module
- Implementation of hook_user().
File
- ./autologout.module, line 500
- Used to automagically log out a user after a preset time, AjK May 2006
Code
function _autologout_invalidate_other_sessions($account) {
if ($account->uid == 0) {
return;
}
$sql = "SELECT COUNT(*) as count FROM {sessions} WHERE uid = '%s' AND sid <> '%s'";
$result = db_result(db_query($sql, $account->uid, session_id()));
if ($result != 0) {
$current_session_msg = t('You are only allowed 1 open session at a time. Your other session has been terminated.');
drupal_set_message($current_session_msg, 'error');
$other_session_msg = t('You have been automatically logged out. You are only allowed 1 open session at a time, and another open session was detected.');
$other_session_msg = 'messages|' . serialize(array(
'error' => array(
$other_session_msg,
),
));
db_query("UPDATE {sessions} SET uid='0', session = '%s' WHERE uid = '%s' AND sid <> '%s'", $other_session_msg, $account->uid, session_id());
watchdog('Automated Logout', t('One Session automatically logged out user.'), array(), WATCHDOG_WARNING);
}
}