I want to store a session value and have that cleared after a set timeout.
I’ve got PHP's session.gc_maxlifetime
set at 60 seconds for development and am using Craft’s HttpSessionService
to set a session value craft()->httpSession->set('foo')
.
I’m then checking that after 60 seconds and would expect it to be cleared by PHP’s session garbage collector but it’s still there: craft()->httpSession->get('foo')
.
I'm aware of how PHP's garbage collection works in that it's not run on every request (1/100 chance by default, defined by other PHP session settings).
What's the best way to force garbage collection on each session? Is there anything under the hood that we can leverage or do we need to write something custom?