[英]Laravel 5 store session in database/redis
I want to use database (currently, MySQL) to store session.我想使用数据库(目前是 MySQL)来存储会话。 But, when I tried to config, table sessions still has no record.但是,当我尝试配置时,表会话仍然没有记录。
In file config/session.php when I change 'driver' => env('SESSION_DRIVER', 'file'),
在文件config/session.php 中,当我更改'driver' => env('SESSION_DRIVER', 'file'),
'driver' => env('SESSION_DRIVER', 'database'),
到'driver' => env('SESSION_DRIVER', 'database'),
'driver' => env('SESSION_DRIVER', 'redis'),
或'driver' => env('SESSION_DRIVER', 'redis'),
What should I change for 'connection' => null,
?我应该为'connection' => null,
更改什么?
I tried:我试过:
'connection' => 'mysql',
with mysql is configured in app/database.php 'connection' => 'mysql',
在app/database.php中配置了mysql'connection' => 'database.connections.mysql',
'connection' => Config::get('database.connections.mysql'),
got class not found error 'connection' => Config::get('database.connections.mysql'),
找不到类错误All you need to do is specify the right driver in the environment file, and generate the schema as outlined in the documentation .您需要做的就是在环境文件中指定正确的驱动程序,并生成文档中概述的架构。
This line:这一行:
'driver' => env('SESSION_DRIVER', 'database')
This is telling the config to get the SESSION_DRIVER
variable from your environment file, and use database
as a default.这告诉配置从您的环境文件中获取SESSION_DRIVER
变量,并使用database
作为默认值。 I can only assume you have forgotten to update your .env
file.我只能假设您忘记更新.env
文件。
我不得不更改 .env 文件 config/session.php 中的 SESSION_DRIVER=database 更改对我不起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.