1
votes

I use default auth from Laravel 5.7, and make some changes to the login page display. I have logged in several times and can run normally, after I stayed a day, and I opened my app again, I found a problem, where the user I last used was still logged in (no logout / user session remained), even though already restarted. when I try to logout (using the logout function) it can get an error

MethodNotAllowedHttpException
No message

I'm not sure, is this a bug from the "Remember me" feature or not. I have been looking for a solution, but I didn't find it, maybe because of my incorrect query.

  • For LoginController, midleware auth etc. it's still in a standard state, I have never changed it

Logout function error logout function

My login form login form

this is my route my route

route list 1 route list

route list

route list 2

1
The thrown exception means there is something wrong with your routes. Please make sure it is defined as a GET route and not as a POST (or something else)! If you don't know what do do please provide us your routes.Romano Schoonheim
no, didn't changed my auth route, i just add some route method for my UserControllerJuliar Nasution
Hmm, strange! Could you provide me the output of php artisan route:list?Romano Schoonheim
i has been update my questionJuliar Nasution
i has been solved, thanksJuliar Nasution

1 Answers

2
votes

Laravel 5.4+ uses post method for logout so instead of simple url (get) request you should post a form to logout.

Try Something Like this

<a href="#" onclick="document.getElementById('logout-form').submit();"> Logout</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
    {{ csrf_field() }}
</form>