/** * 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; }
/** * @magentoConfigFixture current_store web/session/use_frontend_sid 1 */ public function testSetSessionIdFromParam() { $this->assertNotEquals('test_id', $this->_model->getSessionId()); $this->request->getQuery()->set($this->_sidResolver->getSessionIdQueryParam($this->_model), 'test-id'); $this->_model->setSessionId($this->_sidResolver->getSid($this->_model)); $this->assertEquals('test-id', $this->_model->getSessionId()); /* Use not valid identifier */ $this->request->getQuery()->set($this->_sidResolver->getSessionIdQueryParam($this->_model), 'test_id'); $this->_model->setSessionId($this->_sidResolver->getSid($this->_model)); $this->assertEquals('test-id', $this->_model->getSessionId()); }
/** * 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; }
/** * 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; }