Level 122
Logout should be a POST from a form. Not a simple link.
This is a security best practice
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
it shows an error like this: "The GET method is not supported for this route. Supported methods: POST." even route define by auth routes then what is the solution of this? logout functon is public function logout(Request $request) { Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect()->route('login');
}
How do you use it in your view?
Do you have something like this:
<form method="POST" action="{{ route('logout') }}">
@csrf
<button type="submit">
{{ __('Log Out') }}
</button>
</form>
Make sure that it is a <form> it has </form> closed tag and the method is POST.
Please or to participate in this conversation.