Skip to content

Commit 02d652a

Browse files
committed
add session cleanup
1 parent 7800a74 commit 02d652a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

defaults/config.ini.default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ enable_verbose_error_log = true ; internal use only
1818
enable_redirect_message = true ; internal use only
1919
enable_exception_handler = true ; internal use only
2020
enable_error_handler = true ; internal use only
21+
session_cleanup_age_seconds = 1800 ; how old a session must be before messages and CSRF tokens are cleared
2122

2223
[ldap]
2324
uri = "ldap://identity" ; URI of remote LDAP server

resources/init.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
$_SESSION["csrf_tokens"] = [];
4343
}
4444

45+
// https://stackoverflow.com/a/1270960/18696276
46+
if (time() - ($_SESSION["LAST_ACTIVITY"] ?? 0) > CONFIG["site"]["session_cleanup_age_seconds"]) {
47+
$_SESSION["csrf_tokens"] = [];
48+
$_SESSION["messages"] = [];
49+
}
50+
$_SESSION["LAST_ACTIVITY"] = time();
51+
4552
if (isset($_SERVER["REMOTE_USER"])) {
4653
// Check if SSO is enabled on this page
4754
$SSO = UnitySSO::getSSO();

0 commit comments

Comments
 (0)