You are here

public function SessionLimit::sessionDisconnect in Session Limit 2.x

Same name and namespace in other branches
  1. 8 src/Services/SessionLimit.php \Drupal\session_limit\Services\SessionLimit::sessionDisconnect()

Disconnect a sessionId.

Parameters

string $sessionId: The session being disconnected

string $message: The logout message which must be already translated by this point

1 call to SessionLimit::sessionDisconnect()
SessionLimit::_onSessionCollision__DropOldest in src/Services/SessionLimit.php
React to a session collision by dropping older sessions.

File

src/Services/SessionLimit.php, line 351

Class

SessionLimit

Namespace

Drupal\session_limit\Services

Code

public function sessionDisconnect($sessionId, $message) {
  $serialized_message = '';
  if ($this
    ->hasMessageSeverity() && !empty($message)) {
    $serialized_message = 'messages|' . serialize([
      $this
        ->getMessageSeverity() => [
        $message,
      ],
    ]);
  }
  $this->database
    ->update('sessions')
    ->fields([
    'uid' => 0,
    'session' => $serialized_message,
  ])
    ->condition('sid', $sessionId)
    ->execute();

  // @todo add a watchdog log entry.
}