public function NativeSessionStorage::start

Starts the session.

@api

Return value

boolean True if started.

Throws

\RuntimeException If something goes wrong starting the session.

Overrides SessionStorageInterface::start

1 call to NativeSessionStorage::start()
NativeSessionStorage::getBag in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
Gets a SessionBagInterface by name.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php, line 127

Class

NativeSessionStorage
This provides a base class for session attribute storage.

Namespace

Symfony\Component\HttpFoundation\Session\Storage

Code

public function start() {
  if ($this->started && !$this->closed) {
    return true;
  }

  // catch condition where session was started automatically by PHP
  if (!$this->started && !$this->closed && $this->saveHandler
    ->isActive() && $this->saveHandler
    ->isSessionHandlerInterface()) {
    $this
      ->loadSession();
    return true;
  }
  if (ini_get('session.use_cookies') && headers_sent()) {
    throw new \RuntimeException('Failed to start the session because headers have already been sent.');
  }

  // start the session
  if (!session_start()) {
    throw new \RuntimeException('Failed to start the session');
  }
  $this
    ->loadSession();
  if (!$this->saveHandler
    ->isWrapper() && !$this->saveHandler
    ->isSessionHandlerInterface()) {
    $this->saveHandler
      ->setActive(false);
  }
  return true;
}