Skip to content

Commit

Permalink
Session::clean() clears all null values from the session
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 20, 2023
1 parent adb6a71 commit 9594e28
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Http/Session.php
Expand Up @@ -345,7 +345,19 @@ private function clean(): void
Nette\Utils\Arrays::invoke($this->onBeforeWrite, $this);

$nf = &$_SESSION['__NF'];
foreach ($nf['META'] ?? [] as $name => $foo) {
foreach ($nf['DATA'] ?? [] as $name => $data) {
foreach ($data ?? [] as $k => $v) {
if ($v === null) {
unset($nf['DATA'][$name][$k], $nf['META'][$name][$k]);
}
}

if (empty($nf['DATA'][$name])) {
unset($nf['DATA'][$name], $nf['META'][$name]);
}
}

foreach ($nf['META'] ?? [] as $name => $data) {
if (empty($nf['META'][$name])) {
unset($nf['META'][$name]);
}
Expand Down

0 comments on commit 9594e28

Please sign in to comment.