I have set up Laravel with Redis as the session driver. I'm having a hard time understanding the difference between calling Session
facade and Redis
facade. If session is set up to use Redis, then Session::get('test')
should return the same output as Redis::get('test')
, right?
This is what I have tried with Tinker:
>>> Session::put('test',123);=> null>>> Session::get('test');=> 123// Why is this not 123?>>> Redis::get('test');=> null// Verify that Session is using Redis>>> Session::getDefaultDriver();=> redis
.env file:
REDIS_HOST=redisREDIS_PASSWORD=nullREDIS_PORT=6379SESSION_DRIVER=redisSESSION_CONNECTION=session
database.php
'redis' => ['cluster' => false,'client' => 'predis','default' => ['host' => env('DATA_REDIS_HOST', env('REDIS_HOST', '127.0.0.1')),'password' => env('REDIS_PASSWORD', null),'port' => env('REDIS_PORT', 6379),'database' => 0, ],'session' => ['host' => env('DATA_REDIS_HOST', env('REDIS_HOST', '127.0.0.1')),'password' => env('REDIS_PASSWORD', null),'port' => env('REDIS_PORT', 6379),'database' => 1, ], ],