Automatically delete old sessions
This commit is contained in:
parent
563399081b
commit
950650fd1f
7
api.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];
|
||||
|
|
|
@ -12,3 +12,6 @@ define("DB_SERVER", "localhost");
|
|||
define("DB_USER", "");
|
||||
define("DB_PASS", "");
|
||||
define("DB_CHARSET", "utf8");
|
||||
|
||||
// Sessions more than this many minutes old will be automatically deleted.
|
||||
define("SESSION_EXPIRE_MINUTES", 30);
|
Loading…
Reference in New Issue