function SessionManager::__construct

Same name in other branches
  1. 9 core/lib/Drupal/Core/Session/SessionManager.php \Drupal\Core\Session\SessionManager::__construct()
  2. 8.9.x core/lib/Drupal/Core/Session/SessionManager.php \Drupal\Core\Session\SessionManager::__construct()
  3. 11.x core/lib/Drupal/Core/Session/SessionManager.php \Drupal\Core\Session\SessionManager::__construct()

Constructs a new session manager instance.

Parameters

\Symfony\Component\HttpFoundation\RequestStack $request_stack: The request stack.

\Drupal\Core\Database\Connection $connection: The database connection.

\Drupal\Core\Session\MetadataBag $metadata_bag: The session metadata bag.

\Drupal\Core\Session\SessionConfigurationInterface $session_configuration: The session configuration interface.

\Drupal\Component\Datetime\TimeInterface|null|\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface $time: The time service.

\Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy|\SessionHandlerInterface|null $handler: The object to register as a PHP session handler.

See also

\Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage::setSaveHandler()

File

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

Class

SessionManager
Manages user sessions.

Namespace

Drupal\Core\Session

Code

public function __construct(RequestStack $request_stack, Connection $connection, MetadataBag $metadata_bag, SessionConfigurationInterface $session_configuration, TimeInterface|AbstractProxy|\SessionHandlerInterface|null $time = NULL, $handler = NULL) {
    $options = [];
    $this->sessionConfiguration = $session_configuration;
    $this->requestStack = $request_stack;
    $this->connection = $connection;
    if (!$time || $time instanceof AbstractProxy || $time instanceof \SessionHandlerInterface) {
        @trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and it will be the 5th argument in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
        if ($time instanceof AbstractProxy || $time instanceof \SessionHandlerInterface) {
            $handler = $time;
        }
        $this->time = \Drupal::service(TimeInterface::class);
    }
    parent::__construct($options, $handler, $metadata_bag);
}

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