Laravel logout fail on pressing back button

前端 未结 5 1988
孤独总比滥情好
孤独总比滥情好 2021-01-06 18:17

On logout from my Laravel application using the Laravel logout method:

public function getLogout() 
    {
       Auth::logout();
       return Redirect::to(\         


        
5条回答
  •  庸人自扰
    2021-01-06 18:42

    This isn't actually what you think it is.

    The back button on a browser fetches the last page in its cache for you.

    If you must really prevent this, then you have two options:

    1. Disable caching (usually a bad idea). See How to control web page caching, across all browsers? for that.
    2. Have a JavaScript keep-alive to a resource in the page and redirect the user if this keepalive shows the user is not logged in.

    Personally I'd just blame caching and ignore it. There's also a third option: using the HTML5 history API, but that's probably way over the top.

提交回复
热议问题