Laravel redirect with logout not working

前端 未结 7 1260
夕颜
夕颜 2021-01-30 09:41

I am Using laravel 4 framework\'s. When I used redirect after the Auth::logout(), the redirection was not working. I used View::make() too, but same \"Whoops, looks like somethi

相关标签:
7条回答
  • 2021-01-30 10:14

    here is a sample code from how I handle logging out users on my system using Laravel 4. I am not sure why yours isn't working and it will be great to see your route, and html code that triggers the logout process as well.

    The Route

    Route::get('logout', array('uses'=>'UserController@logout'));
    

    The HTML button/link triggering the logout

    <a href="{{URL::to('logout')}}" class="btn btn-danger btn-sm">Logout</a>
    

    The Controller Function Handling the logout

    public function logout(){
    
        Auth::logout();
    
        return Redirect::to('login');
    }
    

    Here you got! You should replace it with your route names and controller function. This should work! If it doesn't, post your route and html code! Cheers!

    0 讨论(0)
提交回复
热议问题