Starts the session.
@api
boolean True if started.
\RuntimeException If something goes wrong starting the session.
Overrides SessionStorageInterface::start
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;
}