Skip to content

Commit ab8aed0

Browse files
committed
write session data to filesystem immediately on cleanup
1 parent 02d652a commit ab8aed0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

resources/init.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
set_error_handler(["UnityWebPortal\lib\UnityHTTPD", "errorHandler"]);
2222
}
2323

24-
session_start();
25-
2624
if (isset($GLOBALS["ldapconn"])) {
2725
$LDAP = $GLOBALS["ldapconn"];
2826
} else {
@@ -42,10 +40,13 @@
4240
$_SESSION["csrf_tokens"] = [];
4341
}
4442

43+
session_start();
4544
// https://stackoverflow.com/a/1270960/18696276
4645
if (time() - ($_SESSION["LAST_ACTIVITY"] ?? 0) > CONFIG["site"]["session_cleanup_age_seconds"]) {
4746
$_SESSION["csrf_tokens"] = [];
4847
$_SESSION["messages"] = [];
48+
session_write_close();
49+
session_start();
4950
}
5051
$_SESSION["LAST_ACTIVITY"] = time();
5152

0 commit comments

Comments
 (0)