public function PdoSessionHandler::gc

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php, line 104

Class

PdoSessionHandler
PdoSessionHandler.

Namespace

Symfony\Component\HttpFoundation\Session\Storage\Handler

Code

public function gc($lifetime) {

  // get table/column
  $dbTable = $this->dbOptions['db_table'];
  $dbTimeCol = $this->dbOptions['db_time_col'];

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