sshateri's avatar

Laravel Fortify and logout

Hey everyone, Does anyone know how the Laravel Fortify logout route works? and how to use it on a button or on an a tag to logout the current user?

0 likes
3 replies
MichalOravec's avatar

Logout has to be a post request. So with javascript submit a form when you click on the Logout link.

<a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
    Logout
</a>

<form id="logout-form" action="{{ route('logout') }}" method="POST">
    @csrf
</form>
2 likes
sshateri's avatar

thanks for the reply that solved my problem now there is a new question which is how change the redirect path in which the user is being redirected after login out?

Please or to participate in this conversation.