From ba901835470d8212bf7785112f4b2ae6cd2c4d61 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 30 Apr 2024 15:00:37 +0300 Subject: [PATCH] cleanup expired sessions --- example/config.json | 1 + src/server.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/example/config.json b/example/config.json index 45e1654..25a4eba 100644 --- a/example/config.json +++ b/example/config.json @@ -21,6 +21,7 @@ }, "session": { + "timeout":3600, "captcha": { "length":3, diff --git a/src/server.php b/src/server.php index 4297b0a..75b64ff 100644 --- a/src/server.php +++ b/src/server.php @@ -35,7 +35,18 @@ $server->setWelcome( global $config; global $session; - // Init session + // Cleanup expired sessions + foreach ($session as $key => $value) + { + if ($value['time'] + $config->nps->session->timeout < time()) + { + unset( + $session[$key] + ); + } + } + + // Init new session $session[$connect] = [ 'time' => time(),