如何在Laravel 4.2中设置会话超时?

问题描述:

是否存在一种固有的方法来设置会话在特定时间后到期.我当前的设置似乎在30分钟后到期,我想禁用该功能或​​至少增加它,但是我在Laravel中找不到可以设置此设置的任何地方?

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?

检查您的 php.ini ,它具有

Check your php.ini, it has a value for session.gc_maxlifetime (and also session.cookie_lifetime) that sets a limit on how long PHP will allow sessions to last. When Laravel sets the options, it passes cookie_lifetime as the value set in app/config/session.php.

但是,会话不会在达到最大生存期后立即过期.发生的情况是,经过该时间后,会话可以由垃圾收集器删除.

However, sessions are not expired immediately after the max lifetime is reached. What happens is after that amount of time has passed the session is then available to be removed by the garbage collector.

解决问题

一种解决方法是检查您的php.ini文件.您可能定义了以下变量:session.gc_maxlifetime.默认情况下,它设置为1440.只需评论或删除它.

One workaround is to check your php.ini file. You may have this variable defined: session.gc_maxlifetime. By default it is set to 1440. Just comment or delete it.

从这个时候开始,您的会话可以使用session.php配置值正常工作.

From this time on you session may work properly using your session.php config values.