Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ANILAMUHAMMADASHRAF's avatar

Logout route in Auth Routes

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');
}
0 likes
5 replies
Snapey's avatar

Logout should be a POST from a form. Not a simple link.

This is a security best practice

2 likes
Nakov's avatar
Nakov
Best Answer
Level 73

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.

1 like
smacy's avatar

if Auth::routes() is not added to web.php

Route::post('/logout',function(){
 Session::flush();
        
        Auth::logout();

    return redirect()->route('login');
})->middleware('auth');
1 like

Please or to participate in this conversation.