cod*_*ama 17 session laravel-4
是否有固有的方法来设置会话在一段时间后过期.我目前的设置似乎在30分钟后到期,我想禁用它或至少增加它,但我找不到Laravel中可以设置的任何地方?
Mar*_*łek 37
在app/config/session.php你有:
lifetime
允许您以分钟为单位设置会话过期时间的选项(不是以秒为单位)
'lifetime' => 60,
Run Code Online (Sandbox Code Playgroud)
表示会话将在一小时后过期.
这里还有一个设置:
'expire_on_close' => true,
Run Code Online (Sandbox Code Playgroud)
当浏览器关闭时,它决定会话是否会过期.
您可能感兴趣的其他设置也是以下php.ini值:
session.cookie_lifetime = 0
Run Code Online (Sandbox Code Playgroud)
和
session.gc_maxlifetime = 1440
Run Code Online (Sandbox Code Playgroud)
这些是默认值.
第一个意味着将存储会话cookie的时间长度 - 默认值为0(直到浏览关闭).以后怎么了许多人的第二个选项意味着秒 PHP可能破坏这个会话数据.
我说的可能是因为有另外一个选择session.gc_probability在php.ini那决定什么是运行垃圾收集器的机会文件.默认情况下,只有1%的几率在1440秒(24分钟)之后会破坏此会话数据.
Nad*_*_MK 22
检查你的php.ini,它有一个session.gc_maxlifetime(以及session.cookie_lifetime)的值,它设置了PHP允许会话持续多长时间的限制.当Laravel设置选项时,它将cookie_lifetime作为设置的值传递app/config/session.php.
但是,在达到最大生命周期后,会话不会立即过期.发生的事情是在那段时间过后,会话可以被垃圾收集器删除.
解决问题
一种解决方法是检查您的php.ini文件.您可以定义此变量:session.gc_maxlifetime.默认情况下,它设置为1440. 只需注释或删除它.
从此时起,您的session可能会使用session.php配置值正常工作.
ben*_*kah 10
从Laravel 4.1开始,删除了本机PHP会话支持
要配置会话生存期编辑app/config/session.php并设置以下内容:
/* if this is set to 'native' it will use file.
if this is set to 'array' sessions will not persist across requests
effectively expiring them immediately.
*/
'driver' => 'file'
/* number of minutes after which the session is available for Laravel's
built in garbage collection.
Prior to 4.1 you could set this to zero to expire sessions when
the browser closes. See the next option below.
*/
'lifetime' => 60
/* If true sessions will expire when the user closes the browser.
This effectively ignores your lifetime setting above.
Set to false if you want Laravel to respect the lifetime value.
If your config file was written before 4.1 you need to add this.
*/
'expire_on_close' => false,
Run Code Online (Sandbox Code Playgroud)
参考文献:
artisan changes 4.1.*在命令行运行以查看有关native会话驱动程序的说明file
$ artisan changes 4.1.* | grep -i native
-> Native session driver has been replaced by 'file'. Specifying 'native' driver will just use the new file driver.
Run Code Online (Sandbox Code Playgroud)
小智 5
App\Config\Session.php
检查一生......
你也可以设置......
Cookie::make('name', 'value', 60); // 1 hr
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38180 次 |
| 最近记录: |