Nas*_*imi 5 php session laravel
我们可以为Laravel中的每个会话设置到期时间吗?
如果我们可以通过我们创建的每个会话从控制器如何实现?谢谢.
Jom*_*oos 11
您可以通过更改以下lifetime值来更改应用程序范围内的会话生命周期config/session.php:
/*
|--------------------------------------------------------------------------
| 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' => 4320,
'expire_on_close' => false,
Run Code Online (Sandbox Code Playgroud)
现在,如果要控制每个用户的会话生存期,则需要在登录用户之前设置此值.
- 尝试用户是否存在于数据库中
- 如果是,并且他是需要更长会话生命周期的用户,请运行
config(['session.lifetime' => $newLifetime]);- 登录用户
- 享受当前用户更长的会话生命周期
- 来源
您必须进行上述更改LoginController.