SessionHandlerInterface::gc PHP Method

gc() public method

public gc ( $maxlifetime )
    public function gc($maxlifetime);

Usage Example

Ejemplo n.º 1
0
 /**
  * @param \Wandu\Http\Contracts\SessionInterface $session
  * @param \Wandu\Http\Contracts\CookieJarInterface $cookieJar
  * @return \Wandu\Http\Contracts\SessionInterface $session
  */
 public function toCookieJar(SessionInterface $session, CookieJarInterface $cookieJar)
 {
     $sessionName = $this->config['name'];
     // save to handler
     $this->handler->write($session->getId(), serialize($session->getRawParams()));
     // apply to cookie-jar
     $cookieJar->set($sessionName, $session->getId(), (new DateTime())->setTimestamp(time() + $this->config['timeout']));
     // garbage collection
     $pick = rand(1, max(1, $this->config['gc_frequency']));
     if ($pick === 1) {
         $this->handler->gc($this->config['timeout']);
     }
     return $session;
 }
All Usage Examples Of SessionHandlerInterface::gc