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

Breadcrumb

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

function MongoDbSessionHandler::doWrite

Overrides AbstractSessionHandler::doWrite

File

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

Class

MongoDbSessionHandler
Session handler using the MongoDB driver extension.

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

protected function doWrite(string $sessionId, string $data) : bool {
    $ttl = ($this->ttl instanceof \Closure ? ($this->ttl)() : $this->ttl) ?? \ini_get('session.gc_maxlifetime');
    $expiry = $this->getUTCDateTime($ttl);
    $fields = [
        $this->options['time_field'] => $this->getUTCDateTime(),
        $this->options['expiry_field'] => $expiry,
        $this->options['data_field'] => new Binary($data, Binary::TYPE_GENERIC),
    ];
    $write = new BulkWrite();
    $write->update([
        $this->options['id_field'] => $sessionId,
    ], [
        '$set' => $fields,
    ], [
        'upsert' => true,
    ]);
    $this->manager
        ->executeBulkWrite($this->namespace, $write);
    return true;
}

API Navigation

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