Spacex
Spacex

Reputation: 37

How to use redis as session caching in Laravel

I want to use redis for storing the user session in my laravel app, my question is do I need to change anything more except the config/session.php

'driver' => env('SESSION_DRIVER', 'redis'),

Upvotes: 0

Views: 1615

Answers (1)

Amitesh Bharti
Amitesh Bharti

Reputation: 15775

As you already have changed default cache driver as redis by following code 'default' => env('CACHE_DRIVER', 'redis'),

In order to make redis function for your application ensure following things :

Before using a Redis cache with Laravel, you will need to either install the predis/predis package (~1.0) via Composer or install the PhpRedis PHP extension via PECL.

Configuration for your application

The Redis configuration for your application is located in the config/database.php configuration file. Within this file, you will see a redis array containing the Redis servers utilized by your application:

'redis' => [

    'client' => 'predis',

    'default' => [
        'host' => env('REDIS_HOST', 'localhost'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => 0,
    ],

],

The default server configuration should suffice for local development.

Upvotes: 1

Related Questions