Reputation: 2893
I am trying to understand Laravels session handler and can't find anything online. At the moment, in session.php
I am doing
'lifetime' => 10,
I have the session driver set to file. So from what I have read, this sets the idle timeout of the session to 10 minutes.
So what does idle mean in this case? I am assuming it means if no request is sent to the server within 10 minutes it will expire. Is this correct?
Also, how can it tell if no request has been sent within 10 minutes? I have taken a look at the session file within storage, and I do not see any timestamp.
So how exactly does all of this work?
Thanks
Upvotes: 2
Views: 1202
Reputation: 9161
Yes you are correct: if you don't send any request after the lifetime config value the session will be destroyed.
The Illuminate\Session\FileSessionHandler
class has a gc()
function, it is a garbage collector function that has a probability to be called on every request, you can control the chances with the session.lottery
config value. This function destroy each session file that has a modified timestamp older than now - lifetime.
You can find the Illuminate\Session\FileSessionHandler
class in the file vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php
if you want to take a look at the source code.
Upvotes: 1