Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 store session in database/redis

Tags:

php

laravel-5

I want to use database (currently, MySQL) to store session. 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'),

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

What should I change for 'connection' => null,?

I tried:

  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
like image 959
Gia Duong Duc Minh Avatar asked Apr 13 '15 05:04

Gia Duong Duc Minh


1 Answers

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. I can only assume you have forgotten to update your .env file.

like image 93
Scopey Avatar answered Oct 02 '22 08:10

Scopey