Browser back button after log out

一世执手 提交于 2019-12-06 03:37:44

问题


How can i prevent browser using the cached copy of the page after log out ?

When user logged out still they can access the previous pages by using the back button.

I understand that we cannot disable the back button (as per SO answers).

Currently i have a large number of pages in different scenarios so i cannot modify each and every page.

What i have tried

  1. Setting the expire header (do i need to set this on each and every page ? also if i do this does browser cache the page contents ? ( because i need the browser to cache contents if user is logged in ))
  2. I have already a polling system ( but still there is a delay to detect )
  3. Javascript based solution ( it works, but still users can use history option to navigate or a long press in back button )

I am really stuck here , Could you please help me to solve the problem ?


回答1:


I think this code will help you, use this code in parent controller constructor.

//Log out Back
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.



回答2:


This is the link answers all.

http://www.codeproject.com/Tips/549347/Browser-Back-Button-Issue-After-Logout

I tried above all solutions but browser incompatible.

So better way is to do Ajax post or in page load check for session var null or not.

This tip also has a limitation that when user clicks the back button of the browser, the back page shows for 1 or half second because of executing the WebMethod. but works for sure in all version of any browser!!



来源:https://stackoverflow.com/questions/17780205/browser-back-button-after-log-out

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!