示例#1
0
 /**
  * Sets the number of seconds before a page cached on a browser expires.
  * @param  string|int|DateTime  time, value 0 means "until the browser is closed"
  * @return self
  * @throws XApp_InvalidStateException  if HTTP headers have been sent
  */
 public function setExpiration($time)
 {
     if (!$time) {
         // no cache
         $this->setHeader('Cache-Control', 's-maxage=0, max-age=0, must-revalidate');
         $this->setHeader('Expires', 'Mon, 23 Jan 1978 10:00:00 GMT');
         return $this;
     }
     $time = Xapp_DateTime::from($time);
     $this->setHeader('Cache-Control', 'max-age=' . ($time->format('U') - time()));
     $this->setHeader('Expires', self::date($time));
     return $this;
 }
示例#2
0
 /**
  * Enables log out after inactivity.
  * @param  string|int|DateTime Number of seconds or timestamp
  * @param  int Log out when the browser is closed | Clear the identity from persistent storage?
  * @return self
  */
 public function setExpiration($time, $flags = 0)
 {
     $section = $this->getSessionSection(TRUE);
     if ($time) {
         $time = Xapp_DateTime::from($time)->format('U');
         $section->expireTime = $time;
         $section->expireDelta = $time - time();
     } else {
         unset($section->expireTime, $section->expireDelta);
     }
     $section->expireIdentity = (bool) ($flags & self::CLEAR_IDENTITY);
     $section->expireBrowser = (bool) ($flags & self::BROWSER_CLOSED);
     $section->browserCheck = TRUE;
     $section->setExpiration(0, 'browserCheck');
     $section->setExpiration($time, 'foo');
     // time check
     return $this;
 }