开发者

Back button help

开发者 https://www.devze.com 2023-01-23 23:23 出处:网络
Hi guys i have a problem with the browsers back button when i click on it. 开发者_如何学GoThe problem is I log into my webapp and the home page appears. when i click the back button of the browser.

Hi guys i have a problem with the browsers back button when i click on it.

开发者_如何学Go

The problem is I log into my webapp and the home page appears. when i click the back button of the browser. i can see the login page. But i don't want this to happen i want the session to be maintained throught till i click the log out button.

How to achieve this?


Since this is a dynamic webapp you need to set the appropriate http headers which will "kill" any browser or proxy cache. The usual recipe is:

response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
response.setHeader("Pragma", "no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server

That way, going back to the login screen should fetch the page from server. And if your server side logic is correct, you will redirect the user to his home page or dashboard since he is already logged in.

0

精彩评论

暂无评论...
验证码 换一张
取 消