2 questions
Where Laravel suggest to regenerate the session at logout?
Why do you return to view logout?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Ok, I am using Laravel UI, not Breeze or Jetstream or Fortify. So on my logout function I clear the existing sessions and regenerate to avoid session fixation.
public function logout(Request $request){
Auth::logout();
$request->session()->flush();
$request->session()->regenerate();
return view('auth/logout');
However this is a pain, as when you go to login again later, the new session has of course timed out, and I get a 419 error, session timed out , which I have adapted to give a meaning full user message. But still, the user now has to close that specific webpage and create a new tab to login - what a pain.
So - the easy answer is just don't regenerate the session. But the Laravel docs suggest I should .... so do I have any better options? Can I just remove the session()->regenerate()?
Many thanks!
Please or to participate in this conversation.