Laravel redirect with logout not working

前端 未结 7 1264
夕颜
夕颜 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条回答
  •  闹比i
    闹比i (楼主)
    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

    Logout
    

    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!

提交回复
热议问题