Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MongoDbSessionHandler.php

function MongoDbSessionHandler::doRead

Overrides AbstractSessionHandler::doRead

File

vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php, line 161

Class

MongoDbSessionHandler
Session handler using the MongoDB driver extension.

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

protected function doRead(string $sessionId) : string {
    $cursor = $this->manager
        ->executeQuery($this->namespace, new Query([
        $this->options['id_field'] => $sessionId,
        $this->options['expiry_field'] => [
            '$gte' => $this->getUTCDateTime(),
        ],
    ], [
        'projection' => [
            '_id' => false,
            $this->options['data_field'] => true,
        ],
        'limit' => 1,
    ]));
    foreach ($cursor as $document) {
        return (string) $document->{$this->options['data_field']} ?? '';
    }
    // Not found
    return '';
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal