php – Laravel 7 Session Lifetime

2021-10-09 16:27:43 浏览数 (1)

根据Laravel config / session.php

代码语言:javascript复制
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/

'lifetime' => 120,
'expire_on_close' => true,
'expired-session-redirect' => url(env('APP_URL'))

我已将会话的生命周期设置为120分钟,但我感觉我的用户在120分钟之前已注销.

这是一个错字吗?它们意味着120秒,即2分钟?

任何人都可以对此有所了解吗?

检查你的php.ini:

session.gc_maxlifetime – 默认1440秒 – 24分钟

session.gc_maxlifetime specifies the number of seconds after which data will be seen as ‘garbage’ and potentially cleaned up. Garbage collection may occur during session start (depending on session.gc_probability and session.gc_divisor).

session.cookie_lifetime – 默认值0

session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means “until the browser is closed.” Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params().

如果它的时间少于Laravel配置,则cookie将被删除,因为本地php.ini优先于Laravel配置.

你可以增加它或评论/删除.

如果没有解决你的应用程序上的东西正在破坏会话.

0 人点赞