Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

looper's avatar

Laravel redis session not working

Hello,

I am trying to use redis instead of file session storage but it seems not working.

config\session.php configured as:

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

Controller function seems as:

public function list(Request $request)
{
    $request->session()->put("test", "demo");
    $val = $request->session()->get("test", "default");

    return view('cat-viviendas', ["val" => $val]);
}

Code works but I see it is being stored at storage\framework\sessions\session_file instead of redis. Any idea why it is not stored in redis?

Regards

0 likes
3 replies
cracker182's avatar
Level 23

Hi, only to be sure, you changed the SESSION_DRIVER=file to SESSION_DRIVER=redis in you .env-file, right?

Greetings

looper's avatar

Right. It was the problem. Why is necessary to modify both session.php and .env files?

Regards

cracker182's avatar

this statement works like this:

'driver' => env('SESSION_DRIVER', 'redis'),
// look in the .env if you find a variable SESSION_DRIVER
// take it's value, if not default to 'redis'

The .env file has an entry SESSION_DRIVER so this value is taken

Please or to participate in this conversation.