function SessionHandler::doRead

File

core/lib/Drupal/Core/Session/SessionHandler.php, line 47

Class

SessionHandler
Default session handler.

Namespace

Drupal\Core\Session

Code

public function doRead(#[\SensitiveParameter] string $sessionId) : string {
  $data = '';
  if (!empty($sessionId)) {
    try {
      // Read the session data from the database.
      $query = $this->connection
        ->queryRange('SELECT [session] FROM {sessions} WHERE [sid] = :sid', 0, 1, [
        ':sid' => Crypt::hashBase64($sessionId),
      ]);
      $data = (string) $query->fetchField();
    } catch (\Exception) {
    }
  }
  return $data;
}

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