laravelredisenvironment-variableslaravel-5.3driver

What is the difference between SESSION_DRIVER=file and SESSION_DRIVER=redis in env laravel?


I use laravel 5.3

In my localhost, the env like this :

CACHE_DRIVER=redis
SESSION_DRIVER=file
QUEUE_DRIVER=redis

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

In my production, the env like this :

CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_DRIVER=redis

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

Almost all the same, just SESSION_DRIVER different

What is the difference between SESSION_DRIVER=file and SESSION_DRIVER=redis?


Solution

  • session driver file stores session data in a file, redis driver stores session data in redis, redis driver is obviously faster. For example

    Session::set('user', $user); //this is stored in file or redis
    Session::get('user'); //this is get from file or redis