Prevent Browser's Back Button Login After Logout in Laravel 5

前端 未结 8 810
情歌与酒
情歌与酒 2020-12-01 02:50

I am new to Laravel 5 and trying to make a simple authentication page. My problem is i can logout properly after i click to logout link but if i click to back button of the

8条回答
  •  长情又很酷
    2020-12-01 03:41

    A method I have used is to simply redirect to the previous page after logout. So long as the previous page was secured, the auth middleware will kick in and redirect you back to the login page. Now when you click the back button the previous page is no longer cached and you just get the login page again.

    Original discussion: https://laracasts.com/discuss/channels/requests/back-button-browser

    public function logout() {
            Auth::logout(); // logout user
            return redirect(\URL::previous());
    }
    

提交回复
热议问题