0

I have a website served over https. We added a simple functionality to a fully functional website, which uses sessions. Everything works great...except the single little session call.

Route::get('/mode/switch', 'ProductController@switch')->name('products.list.mode'); // AJAX call


 public function switch(Request $request)
 {
     session()->put('list_mode', $request->input('mode') ?? 'grid');
     return response()->json(['success'=>true])->setStatusCode(202);
 }
[...] echo session()->get('list_mode'); // null

If I try to echo the session after setting it, everything is great (as is expected). However, when I refresh the page, the session's value is null. But sessions are used elsewhere in the site, in the same page, and are working just fine.

The relevant configs:

['secure'=>true, 'http_only'=>false, 'encrypt'=>true]

It also works fine on an non-https environment (with all config set to "non-secure"). However, for the life of me, I can't figure out why only this value is not set properly.

Thanks

user1453870
  • 471
  • 5
  • 9

0 Answers0