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

chanpw_'s avatar

Laravel session with redis

I want to store the session to redis in Laravel. I was set the session_driver to redis in .env Also set my redis server.

I use this code for storing the session $req->session()->put($email, json_encode($user));

At first, I understand why they keep storing for every methods that hit by users. That because default router has included with 'web' middleware, i already change that. So, just some function can store to redis.

But when I want to get the data, it keep always replace/re-set the data. For example, my data before has expire 6000 seconds. After I get the data, it become 7200 seconds(default).

How can I get the data without re-set the data?

0 likes
0 replies

Please or to participate in this conversation.