Use 'web' middleware'.
Laravel 5.2: User not logged out after session timeout
Hi.
I have a situation where user is still logged in after session expires (lifetime set to 1). My dashboard is under the auth middleware, so after session expiry I start debugging, and every link is taking mi to the Authenticate.php and the handler method:
public function handle($request, Closure $next)
{
if ($this->auth->guest()){
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
return $next($request);
}
The problem is that $this->auth->guest() returns false, every time. Auth::check() returns true.
So, the user is still logged in. I thought I solved the issue by setting session domain to null, but that backfired elsewhere, sessions went nuts and I couldn't keep my navbar links in order because Auth::check() was working irregularely.
Now my session domain is '.app.tech', because I have subdomains, and logging in and logging out works fine, everything is in place. The only thing not working is Auth when session expires. $this->auth->guest() returns false and the dashboard controller is called which later fails because user id can't be fetched from the expired session.
Any help? Tell me if you need more information.
Please or to participate in this conversation.