Skip to content

Commit

Permalink
Enable session GC on servers that disable it
Browse files Browse the repository at this point in the history
  • Loading branch information
zerocrates committed Aug 21, 2024
1 parent 721a575 commit 4b6ea4f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions application/src/Mvc/MvcListeners.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ public function bootstrapSession(MvcEvent $event)
'use_only_cookies' => true,
'gc_maxlifetime' => 1209600,
];

// Override PHP defaults that configure for no GC
if (empty($config['session']['allow_no_gc']) && ini_get('session.gc_probability') == 0) {
$defaultOptions['gc_probability'] = 1;
$defaultOptions['gc_divisor'] = 1000;
}

$userOptions = $config['session']['config'] ?? [];
$sessionConfig->setOptions(array_merge($defaultOptions, $userOptions));

Expand Down

0 comments on commit 4b6ea4f

Please sign in to comment.