1.安装Redis依赖包
composer require predis/predis
2.打开config/database.php。在redis配置项中增加session的连接
'session' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => 10, ],
3.打开config/session.php
,修改driver配置项,将默认的file
改为redis
;connection
配置项填入第一步中配置的redis连接名session
4.修改.env文件,使用redis存取sessoin
SESSION_DRIVER=file 修改为 SESSION_DRIVER=redis
from:https://www.jianshu.com/p/5b6dbc7ff570