讨论数量:
首先不管是 php session
还是 laravel session
,lifetime
都不是到时间就删除。
这个问题我之前还回答过 -> 问答:请教大家 Laravel7 session 生产周期问题
laravel
的好处在于它实现了多种驱动,不同驱动通过实现 gc()
方法清理过期 session
。
可参考 SessionHandlerInterface::gc
以及 laravel
不同驱动的实现方式。
而 gc()
的调用时机可在 session.php
配置文件中设置,默认是 2% 几率
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [2, 100],
推荐文章: