简体   繁体   English

Laravel 5 在数据库/redis 中存储会话

[英]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'),

  1. to 'driver' => env('SESSION_DRIVER', 'database'),'driver' => env('SESSION_DRIVER', 'database'),
  2. or 'driver' => env('SESSION_DRIVER', 'redis'),'driver' => env('SESSION_DRIVER', 'redis'),

What should I change for 'connection' => null, ?我应该为'connection' => null,更改什么?

I tried:我试过:

  1. 'connection' => 'mysql', with mysql is configured in app/database.php 'connection' => 'mysql',app/database.php中配置了mysql
  2. 'connection' => 'database.connections.mysql',
  3. '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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM