Laravel 5在数据库/Redis中存储会话 [英] Laravel 5 store session in database/redis
本文介绍了Laravel 5在数据库/Redis中存储会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用数据库(当前为MySQL)存储会话.但是,当我尝试配置时,表会话仍然没有记录.
I want to use database (currently, MySQL) to store session. But, when I tried to config, table sessions still has no record.
当我更改'driver' => env('SESSION_DRIVER', 'file'),
- 到
'driver' => env('SESSION_DRIVER', 'database'),
- 或
'driver' => env('SESSION_DRIVER', 'redis'),
- to
'driver' => env('SESSION_DRIVER', 'database'),
- or
'driver' => env('SESSION_DRIVER', 'redis'),
我应该为'connection' => null,
更改什么?
我尝试过:
-
在 app/database.php 中配置了带有 mysql 的
-
'connection' => 'mysql',
-
'connection' => 'database.connections.mysql',
-
'connection' => Config::get('database.connections.mysql'),
找不到类错误
'connection' => 'mysql',
with mysql is configured in app/database.php'connection' => 'database.connections.mysql',
'connection' => Config::get('database.connections.mysql'),
got class not found error
推荐答案
All you need to do is specify the right driver in the environment file, and generate the schema as outlined in the documentation.
此行:
'driver' => env('SESSION_DRIVER', 'database')
这是告诉配置从您的环境文件中获取SESSION_DRIVER
变量,并使用database
作为默认值.我只能假设您忘记更新您的.env
文件.
This is telling the config to get the SESSION_DRIVER
variable from your environment file, and use database
as a default. I can only assume you have forgotten to update your .env
file.
这篇关于Laravel 5在数据库/Redis中存储会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文