Ver código fonte

Automatically delete old sessions

master
Skylar Ittner 4 anos atrás
pai
commit
950650fd1f
  1. 7
      api.php
  2. 5
      settings.template.php

7
api.php

@ -3,6 +3,13 @@
require __DIR__ . '/required.php';
header("Content-Type: application/json");
// Oldest session allowed
$session_min_date = date("Y-m-d H:i:s", strtotime("-" . SESSION_EXPIRE_MINUTES . " minutes"));
// Delete old sessions
$old_sessions = $database->select("sessions", "sid", ["timestamp[<]" => $session_min_date]);
$database->delete("scrambled_answers", ["sid" => $old_sessions]);
$database->delete("sessions", ["sid" => $old_sessions]);
switch ($VARS['action']) {
case "ping":
$out = ["status" => "OK", "pong" => true];

5
settings.template.php

@ -11,4 +11,7 @@ define("DB_NAME", "captcheck");
define("DB_SERVER", "localhost");
define("DB_USER", "");
define("DB_PASS", "");
define("DB_CHARSET", "utf8");
define("DB_CHARSET", "utf8");
// Sessions more than this many minutes old will be automatically deleted.
define("SESSION_EXPIRE_MINUTES", 30);
Carregando…
Cancelar
Salvar