cleanup old containers

This commit is contained in:
Roland Gruber 2019-05-30 17:19:45 +02:00
parent 49423d778c
commit 86e37191fa
1 changed files with 17 additions and 0 deletions

View File

@ -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'])) {