That's expected Behavior no different than if you were on a page that required authorization.
You can probably catch the error and redirect to a friendly page with a link to go back to login page.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi All,
I was wondering if anyone else has had an issue where their session expires if they leave their browser open but the nav bar doesn't update to show that I have been logged out. So when I click on something it gives me an error. Does Laravel have any built in way to refresh the browser page when the session has expired?
adjust your middleware so that if the user is not logged in, you redirect them to the login route
public function handle($request, Closure $next)
{
if (Auth::check() && Auth::user()->Admin())
{
return $next($request);
}
return redirect('/login');
}
Adjust for your login route or use named routes
Please or to participate in this conversation.