Ejemplo n.º 1
0
 public function __construct()
 {
     $registry = Zend_Registry::getInstance();
     $configIni = $registry->get('config');
     $db = Zend_Db::factory($configIni->session->config->db->adapter, $configIni->session->config->db->param->toArray());
     $config = array('name' => 'KutuSession', 'primary' => 'sessionId', 'modifiedColumn' => 'sessionModified', 'dataColumn' => 'sessionData', 'lifetimeColumn' => 'sessionLifetime', 'db' => $db);
     parent::__construct($config);
 }
Ejemplo n.º 2
0
 public function testSetLifetime()
 {
     $config = $this->_saveHandlerTableConfig;
     unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]);
     $config['primary'] = array($config['primary'][0]);
     $config['lifetime'] = 1;
     $this->_setupDb($config['primary']);
     $this->_usedSaveHandlers[] = $saveHandler = new Zend_Session_SaveHandler_DbTable($config);
     $this->assertSame(1, $saveHandler->getLifetime());
     $saveHandler->setLifetime(27);
     $this->assertSame(27, $saveHandler->getLifetime());
 }
Ejemplo n.º 3
0
 public function __construct($adapter, $dbParams)
 {
     $db = Zend_Db::factory($adapter, $dbParams);
     $config = array('name' => 'KutuSession', 'primary' => 'sessionId', 'modifiedColumn' => 'sessionModified', 'dataColumn' => 'sessionData', 'lifetimeColumn' => 'sessionLifetime', 'db' => $db);
     parent::__construct($config);
 }
Ejemplo n.º 4
0
 /**
  * @group 9294
  */
 public function testGcWithAutoQuoteIdentifiersEnabledAndDisabled()
 {
     $config = $this->_saveHandlerTableConfig;
     $configDb = array('options' => array('autoQuoteIdentifiers' => false), 'profiler' => true);
     $this->_setupDb($config['primary'], $configDb);
     $config['db'] = $this->_db;
     $saveHandler = new Zend_Session_SaveHandler_DbTable($config);
     $saveHandler->gc(false);
     $lastQuery = $this->_db->getProfiler()->getLastQueryProfile()->getQuery();
     $partQueryExpected = "WHERE (modified + lifetime < ";
     $this->assertContains($partQueryExpected, $lastQuery);
     $configDb = array('options' => array('autoQuoteIdentifiers' => true), 'profiler' => true);
     $this->_setupDb($config['primary'], $configDb);
     $config['db'] = $this->_db;
     $saveHandler = new Zend_Session_SaveHandler_DbTable($config);
     $saveHandler->gc(false);
     $lastQuery = $this->_db->getProfiler()->getLastQueryProfile()->getQuery();
     $partQueryExpected = "WHERE (\"modified\" + \"lifetime\" < ";
     $this->assertContains($partQueryExpected, $lastQuery);
 }
Ejemplo n.º 5
0
 /**
  * Init session
  */
 protected function _initSession()
 {
     if (!$this->_appConfig->session_lifetime) {
         return;
     }
     // session storage db table
     $config = array('name' => 'sessions', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime');
     $saveHandler = new Zend_Session_SaveHandler_DbTable($config);
     // run garbage collector in 1%
     if (rand(1, 100) == 1) {
         $saveHandler->gc(1);
     }
     // make the session persist for x seconds
     $saveHandler->setLifetime($this->_appConfig->session_lifetime, $this->_appConfig->session_lifetime);
     Zend_Session::setSaveHandler($saveHandler);
     Zend_Session::start(array('cookie_lifetime' => $this->_appConfig->session_lifetime));
 }
Ejemplo n.º 6
0
 /**
  * Write session data
  *
  * @param string $id
  * @param string $data
  * @return boolean
  */
 public function write($id, $data)
 {
     parent::write($id, $data);
     // Discard parent's return value and return true (PHP 7 actually cares about this)
     return true;
 }