/**
  * {@inheritdoc}
  */
 public function start()
 {
     if ($this->started && !$this->closed) {
         return true;
     }
     if (version_compare(phpversion(), '5.4.0', '>=') && \PHP_SESSION_ACTIVE === session_status()) {
         throw new \RuntimeException('Failed to start the session: already started by PHP.');
     }
     if (version_compare(phpversion(), '5.4.0', '<') && isset($_SESSION) && session_id()) {
         // not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3
         throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).');
     }
     if (ini_get('session.use_cookies') && headers_sent($file, $line)) {
         throw new \RuntimeException(sprintf('Failed to start the session because headers have already been sent by "%s" at line %d.', $file, $line));
     }
     // ok to try and start the session
     if (!session_start()) {
         throw new \RuntimeException('Failed to start the session');
     }
     $this->loadSession();
     if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) {
         // This condition matches only PHP 5.3 with internal save handlers
         $this->saveHandler->setActive(true);
     }
     return true;
 }
Пример #2
0
 /**
  * @runInSeparateProcess
  * @expectedException \LogicException
  */
 public function testIdExceptionPhp54()
 {
     if (version_compare(phpversion(), '5.4.0', '<')) {
         $this->markTestSkipped('Test skipped, for PHP 5.4 only.');
     }
     session_start();
     $this->proxy->setId('foo');
 }
Пример #3
0
 /**
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  * @expectedException \LogicException
  */
 public function testIdExceptionPhp54()
 {
     if (PHP_VERSION_ID < 50400) {
         $this->markTestSkipped('Test skipped, for PHP 5.4 only.');
     }
     session_start();
     $this->proxy->setId('foo');
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function getBag($name)
 {
     if (!isset($this->bags[$name])) {
         throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name));
     }
     if ($this->saveHandler->isActive() && !$this->started) {
         $this->loadSession();
     } elseif (!$this->started) {
         $this->start();
     }
     return $this->bags[$name];
 }
Пример #5
0
 /**
  * @expectedException \LogicException
  */
 public function testIdException()
 {
     $this->proxy->setActive(true);
     $this->proxy->setId('foo');
 }
Пример #6
0
 /**
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  * @expectedException \LogicException
  */
 public function testIdException()
 {
     session_start();
     $this->proxy->setId('foo');
 }