gcSession() public method

Do not call this method directly.
public gcSession ( integer $maxLifetime ) : boolean
$maxLifetime integer the number of seconds after which data will be seen as 'garbage' and cleaned up.
return boolean whether session is GCed successfully
Exemplo n.º 1
0
 /**
  * Session GC (garbage collection) handler.
  * Do not call this method directly.
  * @param integer $maxLifetime the number of seconds after which data will be seen as 'garbage' and cleaned up.
  * @return boolean whether session is GCed successfully
  */
 public function gcSession($maxLifetime)
 {
     if ($this->dbSession) {
         return $this->dbSession->gcSession($maxLifetime);
     } else {
         parent::gcSession($maxLifetime);
     }
 }
Exemplo n.º 2
0
 /**
  * @depends testReadWrite
  */
 public function testGarbageCollection()
 {
     $session = new DbSession();
     $session->writeSession('new', 'new data');
     $session->writeSession('expire', 'expire data');
     $session->db->createCommand()->update('session', ['expire' => time() - 100], 'id = :id', ['id' => 'expire'])->execute();
     $session->gcSession(1);
     $this->assertEquals('', $session->readSession('expire'));
     $this->assertEquals('new data', $session->readSession('new'));
 }