3

Currently I'm logging into my account. After proceeding some of the pages I have log-out my account. Now if I go back page using back button in browser, still I'm in login state. Is there anyway to set this status as logout?

4

3 回答 3

5

The problem with browsers is that using the back button doesn't refresh the page to any data form a server or force the browser to run any loading JavaScript functions.

What you could do is have a JavaScript function set on a time-out to check if they are logged in every 10 seconds using AJAX.

I wouldn't bother though as you are adding additional server load for no real benefit, as when the user refreshes the page or clicks on a link they would still be logged out and wouldn't be able to perform any logged in actions.

于 2012-04-10T11:23:18.553 回答
0

Most probably, pages get cached in the browser.

Set the application to server pages disabling their caching - thus, going back will reload them from the server and display logged out state, instead of pulling them out from browser cache.

How to do that is out the question scope. Google for 'no-cache' and 'Expires' headers.

于 2012-04-10T11:27:23.933 回答
0

Add nocache tags in <head>...</head> of your secret pages.

<META http-equiv="Pragma" content="no-cache">

This is happening because when you visit a page in your website, the page is automatically cached in browser. And when you go back after logout, those pages are served directly from browser-cache. You need to to disable the cache so that when you come back after logout, those pages get called again from server.

于 2012-04-10T11:34:46.143 回答