public function testCanPassStorageToConstructor() { $storage = new Session\Storage\ArrayStorage(); $manager = new SessionManager(null, $storage); $this->assertSame($storage, $manager->getStorage()); }
/** * If configured aggregate the impact from the report in the session and return the updated value. * @param IDS_Report $report * @return int */ protected function aggregateImpactInSession(IDS_Report $report) { if ($this->config['aggregate_in_session']) { $sessionManager = new SessionManager(); $sessionManager->start(); $session = $sessionManager->getStorage(); if (!isset($session->ZeSecurityIDS)) { $session->ZeSecurityIDS = array('impact' => 0); } $impact = $session->ZeSecurityIDS['impact']; $impact += $report->getImpact(); $session->ZeSecurityIDS['impact'] = $impact; } else { $impact = $report->getImpact(); } return $impact; }
/** * return a session storage instance * @return \Zend\Session\Storage\StorageInterface */ protected function getSession() { $sessionManager = new SessionManager(); $sessionManager->start(); return $sessionManager->getStorage(); }
public function testCanPassStorageClassToConfigurationOptions() { $manager = new SessionManager(array('storage' => 'Zend\\Session\\Storage\\ArrayStorage')); $storage = $manager->getStorage(); $this->assertTrue($storage instanceof Session\Storage\ArrayStorage); }
/** * According to the PHP manual, session_write_close should always be * registered as a shutdown function when using an object as a session * handler: http://us.php.net/manual/en/function.session-set-save-handler.php * * This method sets that up. * * @param SessionManager $sessionManager Session manager instance * * @return void */ protected function registerShutdownFunction(SessionManager $sessionManager) { register_shutdown_function(function () use($sessionManager) { // If storage is immutable, the session is already closed: if (!$sessionManager->getStorage()->isImmutable()) { $sessionManager->writeClose(); } }); }