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

kaya28's avatar

Laravel 5.8 Session (Redis Driver) Reset On Refresh

We are using Laravel 5.8 on an e-commerce website. Some of our customers inform us that they can add any item to their basket. When we look at the log files, we see that those customers' basket is duplicated every time. We release that session is destroyed when page is refreshed.

Interestingly, we do not get this error on the local environment. Also, this issue does not happen every time. I only come across this issue a couple of times in chrome browser. Lastly, the problem only can be solved only if I clear site data on the chrome development console.

Session.php:

'driver' => 'redis',
'lifetime' => 60*24*30,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => 'session',
'table' => 'sessions',
'store' => null,
'lottery' => [2, 100],
'cookie' => 'my_session',
'path' => '/',
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false),
'http_only' => true,

Thanks for advance.

0 likes
4 replies
bobbybouwmann's avatar

It sounds like Redis is being cleared in some way.

Do you have an external Redis server or is it running on the same server?

kaya28's avatar

redis is running on the same server.

bobbybouwmann's avatar

Are you sure the Redis instance is not cleared somewhere somehow? I can't think of anything else that might break this.

kaya28's avatar

To be honest, I am really confused. The following case is what I came across last week. I used Chrome Desktop to test the website. I added 1 item to the cart. But the cart was empty. Then I logged the session at the end of the script. Cart item was available at the log file. When I refresh the page, the session was flushed automatically. However, I open another incognito Chrome tab. I added Item and session not destroyed.

Please or to participate in this conversation.