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

Devmaurice's avatar

Session Persist with Redis

I want to use Redis for my session. I have set up everything and i can die dump the session and see the STORE object when i die and dump. The problem is when i add something on the session i cant see it in the session.

session()->put('user', 'My name');

Now when i refresh and i **dd($request->session()) ** i only see the _token parameter only.

Store {#183 ▼
  #id: "xymEy5TRfwZsmMeWzjkPDBOaYhCs4RqFouI6HRYy"
  #name: "laravel_session"
  #attributes: array:1 [▼
    "_token" => "eoWnt485RzOPypPBQMjqOuw5VzptT0k3Mz7Cc8LK"
  ]
......

Am using Centos 7 as my server.

NB: The session was acting the same even with the file as the driver.

 The redis driver is okay because i have been able to **set** and **get** from the Redis facade.
0 likes
10 replies
jekinney's avatar

If it's not working with file then probably something wrong with your development environment not actually storing any session for some reason.

rickbolton's avatar

Can you check what it returns before you redirect? So straight after you push to the session.

Devmaurice's avatar

@rickbolton yea just after i set it is there but as soon as i redirect all is lost only token is left.

rickbolton's avatar

Are you using 5.3 Laravel? If so can you send the code within your routes/web.php file please?

Devmaurice's avatar

@rickbolton

   Route::get('/', 'CorporateController@page');
    Route::get('/login', 'CorporateController@getLogin');
    Route::post('/user/login', 'CorporateController@login');

just that

MarkLL's avatar

Hi @Devmaurice I suspect it's cause you are using dd(). Basically this destroys the session before it gets saved. Try returning a json version so the session completes correctly. - I've seen the same behavior trying to check the session attributes in a controller.

Devmaurice's avatar

@MarkLL Actually i was trying to do

session()->get('key');

and thats how i realize it was not persisting session so it's not that one

rickbolton's avatar

@Devmaurice

I've also read that wrapping routes in a web middleware can also cause this as this is no longer required. Wasn't sure whether you had this from some old documentation.

Route::group(['middleware' => 'web'], function () {


});

Please or to participate in this conversation.