Support the ongoing development of Laravel.io →
posted 7 years ago
Authentication
Last updated 10 months ago.
0

Use this in routes.php Route::get('auth/logout', 'Auth\[email protected]'); and add <a href="{{ url('/auth/logout') }}" >Logout</a> in your view . It's a builtin functionality. I mean Auth.

0

I also had similar problem in Laravel 5.2. You should change your route to

Route::get('auth/logout', 'Auth\[email protected]');

or in AuthController constructor add

public function __construct()
{
    $this->middleware('guest', ['except' => ['logout', 'getLogout']]);
}

That worked for me.

0

Pawlox said:

I also had similar problem in Laravel 5.2. You should change your route to

Route::get('auth/logout', 'Auth\[email protected]');

or in AuthController constructor add

public function __construct() { $this->middleware('guest', ['except' => ['logout', 'getLogout']]); }

That worked for me.

Thank you , you save my life

0

Thank you too. I have been pulling my hair out.

Which is best practice?

0

Check this

https://laracasts.com/discuss/channels/laravel/logout-wont-wor...

you just need to fix your AuthController

 /**
         * Create a new authentication controller instance.
         *
         * @return void
         */
        public function __construct()
        {
            $this->middleware('guest', [ 'except' => 'logout' ]); // Default router name is "logout" should be same router 

        }

Route::get('logout', [ 'uses' => 'Auth\[email protected]', 'as' => 'logout' ]);

0

Pawlox said:

I also had similar problem in Laravel 5.2. You should change your route to

Route::get('auth/logout', 'Auth\[email protected]');

or in AuthController constructor add

public function __construct() { $this->middleware('guest', ['except' => ['logout', 'getLogout']]); }

That worked for me.

Thanks, bro! Much appreciated!

0

Sign in to participate in this thread!

LoadForge

Your banner here too?

fpena fpena Joined 27 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 Laravel.io - All rights reserved.