I'm building a very simple app in Laravel 5.2, but when using AuthController
's action to log out, it just simply doesn't work. I have a nav bar which checks for Auth::check()
and it doesn't change after calling the log out action.
I have this route inside the routes.php file:
Route::get('users/logout', 'Auth\AuthController@getLogout');
and it's outside the
Route::group(['middleware' => ['web']], function ()
statement.
I did also try to add the follow action at the end of the AuthController.php file.
public function getLogout()
{
$this->auth->logout();
Session::flush();
return redirect('/');
}
Do you have any ideas?
EDIT 1
If I clear Google's Chrome cache, it works.
I also had similar problem in Laravel 5.2. You should change your route to
Route::get('auth/logout', 'Auth\AuthController@logout');
or in AuthController constructor add
public function __construct()
{
$this->middleware('guest', ['except' => ['logout', 'getLogout']]);
}
That worked for me.