Laravel session variable disappears after a while
Hello there, I declare a session variable upon successful login, by doing something like:
session(["myvar" => "something"]);
in LoginController.
The problem is that after a while (session not yet expired), this variable suddenly gets unset. Do you know why?
Is the user still logged in?
@bortz when you loose myvar in session, do you also loose the current login. Try an Auth::check:
if (Auth::check()) {
echo "The user is logged in";
}
@bortz your myvar then should still be available. Check for syntax errors. And show where you are using it where it's not available all of a sudden.
Edit:
I normally use the facade:
Session::put('search', $search);
But the helper should work the exact same.
@jlrdw No errors. The variable is just empty if I show it with dd. Now I'm using the facade too. I will update you about it.
Hi, getting the same issue here In Laravel 8, the user is still logged in yet the session value is gone after a while
Please or to participate in this conversation.