Laravel 5在数据库/Redis中存储会话 [英] Laravel 5 store session in database/redis

查看:252
本文介绍了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'),

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

我应该为'connection' => null,更改什么?

我尝试过:

    app/database.php 中配置了带有 mysql
  1. 'connection' => 'mysql',
  2. 'connection' => 'database.connections.mysql',
  3. 'connection' => Config::get('database.connections.mysql'),找不到错误
  1. 'connection' => 'mysql', with mysql is configured in app/database.php
  2. 'connection' => 'database.connections.mysql',
  3. '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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆