new system prototype
This commit is contained in:
21
cli/cleanup_sessions.php
Normal file
21
cli/cleanup_sessions.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* CLI: Remove expired sessions from the database.
|
||||
* Usage: php cli/cleanup_sessions.php
|
||||
*/
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
http_response_code(403);
|
||||
echo "CLI only\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../common.php';
|
||||
require_once __DIR__ . '/../db_init.php';
|
||||
|
||||
[$pdo, $tmpDb, $lockFp] = qdb_open(true);
|
||||
$stmt = $pdo->prepare("DELETE FROM session WHERE expiresAt < :now");
|
||||
$stmt->execute([':now' => time()]);
|
||||
$removed = $stmt->rowCount();
|
||||
qdb_save($tmpDb, $lockFp);
|
||||
|
||||
echo "Removed $removed expired session(s).\n";
|
||||
Reference in New Issue
Block a user