From 86e37191faa43cdc914062c8a1bd00a8fd395d2a Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 30 May 2019 17:19:45 +0200 Subject: [PATCH] cleanup old containers --- lam/templates/account/edit.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lam/templates/account/edit.php b/lam/templates/account/edit.php index 02ba8be3..e90bc84c 100644 --- a/lam/templates/account/edit.php +++ b/lam/templates/account/edit.php @@ -65,6 +65,23 @@ else { $sessionKey = $sessionAccountPrefix . (new \DateTime(null, getTimeZone()))->getTimestamp() . getRandomNumber(); } +// cleanup account containers in session +$cleanupCandidates = array(); +foreach ($_SESSION as $key => $value) { + if (strpos($key, $sessionAccountPrefix) === 0) { + $cleanupCandidates[] = $key; + } + $candidateCount = sizeof($cleanupCandidates); + if ($candidateCount > 100) { + $numToDelete = $candidateCount - 100; + natsort($cleanupCandidates); + for ($i = 0; $i < $numToDelete; $i++) { + $toDelete = array_shift($cleanupCandidates); + unset($_SESSION[$toDelete]); + } + } +} + $typeManager = new LAM\TYPES\TypeManager(); //load account if (isset($_GET['DN'])) {