what version of laravel you are using?
Route to logout
Hello, does anyone have the route for in the web.php to logout, i think i deleted it :(
@osama_mohamed 5.3
Hi @Robinvm,
This post may help you out: http://stackoverflow.com/a/39197278/1538275
If you are using the authentication scaffolding provided by Laravel you can simply add Auth::routes(); anywhere in your web.php file and all your authentication routes will be included automatically. To answer your question more specifically, the logout route would look something like this in web.php:
Route::post('logout', ['as' => 'logout', 'uses' => 'Auth\LoginController@logout'])
If I get you properly, if you have deleted any information from default package, then can easily add from here https://github.com/laravel/laravel
@user10 im using that auth::routes, how can i logout a user with a button then?
@Robinvm Generally a link to /logout will do the trick.
@JoshMountain i got this but it doesnt work </a href="{{ url('/logout') }}" > without that / at the end
@Robinvm I'm not sure I understand. What happens when you visit yourapp.dev/logout?
@JoshMountain it returns me and does not log me out
Laravel is actually sending POST request to logout these days.. so just linking to '/logout' won't work unless you change the route to Route::get() instead of Route::post()
<ul class="dropdown-menu" role="menu">
<li>
<a href="{{ url('/logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
PS. You can always run php artisan make:auth to generate the files again, just make sure you backup the old ones if you have made any changes in them.
Route::get('/logout', 'Auth\LoginController@logout');
Please or to participate in this conversation.