Nette\Http\SessionSection::setExpiration PHP Метод

setExpiration() публичный Метод

Sets the expiration of the section or specific variables.
public setExpiration ( $time, $variables = NULL ) : self
Результат self
    public function setExpiration($time, $variables = NULL)
    {
        $this->start();
        if ($time) {
            $time = Nette\Utils\DateTime::from($time)->format('U');
            $max = (int) ini_get('session.gc_maxlifetime');
            if ($max !== 0 && $time - time() > $max + 3) {
                // 0 - unlimited in memcache handler, 3 - bulgarian constant
                trigger_error("The expiration time is greater than the session expiration {$max} seconds");
            }
        }
        foreach (is_array($variables) ? $variables : [$variables] as $variable) {
            $this->meta[$variable]['T'] = $time ?: NULL;
        }
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * @param PayPal $payPal
  * @param Session $session
  */
 public function __construct(PayPal $payPal, Session $session)
 {
     parent::__construct();
     $this->payPal = $payPal;
     $this->session = $session->getSection('PayPalExpress');
     $this->session->setExpiration('+10 minutes');
     if (empty($this->session->token)) {
         $this->session->token = $this->_ec = Strings::random(6);
     }
 }
All Usage Examples Of Nette\Http\SessionSection::setExpiration