function SessionManager::delete

Ends a specific user's session(s).

Parameters

int $uid: User ID.

Overrides SessionManagerInterface::delete

File

core/lib/Drupal/Core/Session/SessionManager.php, line 231

Class

SessionManager
Manages user sessions.

Namespace

Drupal\Core\Session

Code

public function delete($uid) {
  // Nothing to do if we are not allowed to change the session.
  if (!$this->writeSafeHandler
    ->isSessionWritable() || $this->isCli()) {
    return;
  }
  // The sessions table may not have been created yet.
  try {
    $this->connection
      ->delete('sessions')
      ->condition('uid', $uid)
      ->execute();
  } catch (\Exception) {
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.