the current version of laravel uses JS for logout when I’m trying to use app over a JS disabled browser its throwing some error. I know not much people disable JS but i want my project to be fully based on PHP instead.
Current code of my app.layout uses:
<li class="nav-item">
<a class="nav-link" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
@csrf
</form>
</li>
I have tried the “Auth:Logout” method as href so when user click on logout it’ll use Auth functions and logout but when I’m doing that app is breaking and logging out user right after logging in!
i can only see one page after login and then it log out by self.
Note:My version of laravel is 6.x and everything is updated.
Thanks
2
Answers
Just put the link inside the form
The style might be off this way, but you can fix it easily
Hope this helps
use logout route