/**
  * Renew session id and update session cookie
  *
  * @return $this
  */
 public function regenerateId()
 {
     if (headers_sent()) {
         return $this;
     }
     if ($this->isSessionExists()) {
         session_regenerate_id(true);
     } else {
         session_start();
     }
     $this->storage->init(isset($_SESSION) ? $_SESSION : []);
     if ($this->sessionConfig->getUseCookies()) {
         $this->clearSubDomainSessionCookie();
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Configure session handler and start session
  *
  * @return $this
  */
 public function start()
 {
     if (!$this->isSessionExists()) {
         \Magento\Framework\Profiler::start('session_start');
         // Need to apply the config options so they can be ready by session_start
         $this->initIniOptions();
         $this->registerSaveHandler();
         // potential custom logic for session id (ex. switching between hosts)
         $this->setSessionId($this->sidResolver->getSid($this));
         session_start();
         $this->validator->validate($this);
         register_shutdown_function(array($this, 'writeClose'));
         $this->_addHost();
         \Magento\Framework\Profiler::stop('session_start');
     }
     $this->storage->init(isset($_SESSION) ? $_SESSION : array());
     return $this;
 }
Esempio n. 3
0
 /**
  * Configure session handler and start session
  *
  * @param string $sessionName
  * @return $this
  */
 public function start($sessionName = null)
 {
     if (!$this->isSessionExists()) {
         \Magento\Framework\Profiler::start('session_start');
         if (!empty($sessionName)) {
             $this->setName($sessionName);
         }
         $this->registerSaveHandler();
         // potential custom logic for session id (ex. switching between hosts)
         $this->setSessionId($this->sidResolver->getSid($this));
         session_start();
         $this->validator->validate($this);
         register_shutdown_function(array($this, 'writeClose'));
         $this->_addHost();
         \Magento\Framework\Profiler::stop('session_start');
     }
     $this->storage->init(isset($_SESSION) ? $_SESSION : array());
     return $this;
 }
Esempio n. 4
0
 /**
  * Configure session handler and start session
  *
  * @throws \Magento\Framework\Exception\SessionException
  * @return $this
  */
 public function start()
 {
     if (!$this->isSessionExists()) {
         \Magento\Framework\Profiler::start('session_start');
         try {
             $this->appState->getAreaCode();
         } catch (\Magento\Framework\Exception\LocalizedException $e) {
             throw new \Magento\Framework\Exception\SessionException(new \Magento\Framework\Phrase('Area code not set: Area code must be set before starting a session.'), $e);
         }
         // Need to apply the config options so they can be ready by session_start
         $this->initIniOptions();
         $this->registerSaveHandler();
         // potential custom logic for session id (ex. switching between hosts)
         $this->setSessionId($this->sidResolver->getSid($this));
         session_start();
         $this->validator->validate($this);
         register_shutdown_function([$this, 'writeClose']);
         $this->_addHost();
         \Magento\Framework\Profiler::stop('session_start');
     }
     $this->storage->init(isset($_SESSION) ? $_SESSION : []);
     return $this;
 }