Is there an inherent way to setup sessions to expire after a certain time. My current setup seems to be expiring after 30 minutes and I would like to disable that or at least increase it, but I can't find any places in Laravel where this could be set?

推荐答案

In app/config/session.php you have:

lifetime

option that allow you to set session expire time in minutes (not in seconds)

'lifetime' => 60,

意味着该会话将在一小时后到期.

There is also one more setting here:

'expire_on_close' => true,

这决定了浏览器关闭时会话是否过期.

您可能感兴趣的其他设置还有php.ini个值:

session.cookie_lifetime = 0

session.gc_maxlifetime = 1440

Those are default values.

The first one means how long session cookie will be stored - default value is 0 (until browse is closed). The second option means after how many of seconds PHP may destroy this session data.

我说可能是因为php.ini文件中还有一个选项session.gc_probability决定了运行垃圾收集器的可能性.默认情况下,1440秒(24分钟)后,该会话数据被销毁的几率仅为1%.

Laravel相关问答推荐

Inertia React中的错误文件上传更新

工厂多对多数据透视表属性

Laravel:在行的子集上同步多对多

laravel 如何验证跨越午夜的两个值之间的时间(15:00 > 时间 > 01:00)

如何在自引用表上使用 Laravel 的 hasManyThrough

在 laravel 5.3 中截断的错误日志(log)

RuntimeException 未安装 Zip PHP 扩展

为什么 laravel 模型会重复一组数据以及如何(如果可能)只有一组数据?

错误try 访问 null 类型值的数组偏移量laravel 5.8.26 Php 7.4.2

如何仅从 laravel FormRequest 中获取经过验证的数据?

Laravel 判断约束违规

php Laravel-遇到格式不正确的数值(在字符串上)

Laravel 同步错误

反向代理后面的 Laravel 路由

Laravel 错误声明 App\Exceptions\Handler::report(Throwable $exception)

Laravel 5 Carbon 全局语言环境

assets资源不引用公用文件夹(Laravel)

如何在 Laravel Mix 中将公共路径更改为包含下划线的内容?

如何在 Laravel 中显示动态复选框的旧数据?

在 Laravel 中判断会话超时