Nette\Http\Session::setExpiration PHP Method

setExpiration() public method

Sets the amount of time allowed between requests before the session will be terminated.
public setExpiration ( $time ) : self
return self
    public function setExpiration($time)
    {
        if (empty($time)) {
            return $this->setOptions(['gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME, 'cookie_lifetime' => 0]);
        } else {
            $time = Nette\Utils\DateTime::from($time)->format('U') - time();
            return $this->setOptions(['gc_maxlifetime' => $time, 'cookie_lifetime' => $time]);
        }
    }

Usage Example

 /**
  * @param string
  * @param string
  * @return void
  * @throws \Nette\InvalidStateException
  */
 private function setSession($uid, $word)
 {
     if (!self::$session) {
         throw new \Nette\InvalidStateException(__CLASS__ . ' session not found');
     }
     self::$session->{$uid} = $word;
     self::$session->setExpiration($this->getExpire(), $uid);
 }
All Usage Examples Of Nette\Http\Session::setExpiration