avoid go back after logout

后端 未结 2 1201
礼貌的吻别
礼貌的吻别 2021-01-25 15:51

i found these questions, where the op has the same problem than me.

1 2

However, i can\'t solve my problem. The user press logout button, then the page is redi

2条回答
  •  -上瘾入骨i
    2021-01-25 16:11

    Even though the user can press the back button and see the previous page which was protected by login, doesn't mean the user is logged in again. They can't do anything - it is just a static copy of a page they previously viewed.

    It is normal behaviour that the user can press the back button and see previous pages, and sites should not attempt to break this. It is a browser feature.

    In most circumstances, it is safe to allow the back button to operate normally even while a user is logged in. Breaking the back button while a user is logged in would have bad usability consequences for the user. In order to prevent a user returning to a page after logging out, you'd have to make sure all pages they view while logged in cannot be returned to with the back button, which breaks the back button for their entire session.

    There are methods you can use to try and disable the back button for logged in sessions, such as by declaring a page to be uncacheable (and unstorable). These may or may not offer varying degrees of protection against back button use. There are plenty of other questions on stackoverflow about disabling the back button - if you want to ignore advice and try to prevent it, please check it out.

提交回复
热议问题