You are here

function remember_me_manage_phantom_sessions in Remember me 5.2

Manage phantom sessions.

When a user closes their browser their session cookie expires. If the user chose to be forgotten they will not be allowed to use the old session. These phantom sessions still appear in Who's online block and will show duplicate names. If configured to do so, via settings page, set phantom session's timeout period outside of the Who's online block's display period.

1 call to remember_me_manage_phantom_sessions()
remember_me_user in ./remember_me.module
Implementation of hook_user().

File

./remember_me.inc, line 17
Functions that are not needed at all times can be included when required.

Code

function remember_me_manage_phantom_sessions() {
  global $user;
  $interval = time() - variable_get('user_block_seconds_online', 900);
  $count = db_result(db_query("SELECT COUNT(uid) FROM {sessions} WHERE uid = %d AND timestamp >= %d", $user->uid, $interval));
  if ($count > 0) {
    watchdog('remember_me', t('Phantom session managed for %user, session trapped within %time timeout.', array(
      '%user' => $user->name,
      '%id' => $user - uid,
      '%time' => format_interval(variable_get('user_block_seconds_online', 900)),
    )), WATCHDOG_NOTICE);
    db_query("UPDATE {sessions} SET timestamp = %d WHERE uid = %d AND timestamp >= %d", $interval - 1, $user->uid, $interval);
  }
}