You are here

public function LegacyPdoSessionHandler::gc in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Session/Storage/Handler/LegacyPdoSessionHandler.php \Symfony\Component\HttpFoundation\Session\Storage\Handler\LegacyPdoSessionHandler::gc()

File

vendor/symfony/http-foundation/Session/Storage/Handler/LegacyPdoSessionHandler.php, line 133

Class

LegacyPdoSessionHandler
Session handler using a PDO connection to read and write data.

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

public function gc($maxlifetime) {

  // delete the session records that have expired
  $sql = "DELETE FROM {$this->table} WHERE {$this->timeCol} < :time";
  try {
    $stmt = $this->pdo
      ->prepare($sql);
    $stmt
      ->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT);
    $stmt
      ->execute();
  } catch (\PDOException $e) {
    throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e
      ->getMessage()), 0, $e);
  }
  return true;
}