Level 25
The problem is your browser is probably caching the content, so is not even hitting your middleware. If you try setting the cache content to no-cache and no-store, does that solve your problem?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have multi guard, i want to prevent showing login page after user is logged-in and hit browser back button. i edited RedirectIfAuthenticated Class as below
public function handle(Request $request, Closure $next, string ...$guards): Response
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if ($guard == 'students' && Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::STUDENTS);
}
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
but still not working
Please or to participate in this conversation.