简体   繁体   English

从浏览器按钮前进/后退时如何使网页过期

[英]How to expire webpage when back/forward from browser button

I want to implement following features to my one of the website project; 我想为我的网站项目之一实现以下功能;

  1. I Don't want to let user navigate between pages. 我不想让用户在页面之间导航。 Page must be expired. 页面必须已过期。 Like onlinesbi or some other secure site. 像onlinesbi或其他安全站点。
  2. If user log out > go back > refresh then again he logs in (currently). 如果用户注销>返回>刷新,则他将再次登录(当前)。 I have to disable such login. 我必须禁用这种登录。

I am already setting no-cache through meta tag 我已经通过meta标签设置了no-cache

Please let me know how to implement above features. 请让我知道如何实现上述功能。

http://www.mnot.net/cache_docs/ http://www.mnot.net/cache_docs/

This HTTP header: 此HTTP标头:

Cache-Control: public, no-cache 缓存控制:公共,无缓存

Take a look at that document! 看看那个文件!

You can place HTTP headers with instructions about how the browser should cache the page. 您可以放置​​HTTP标头,其中包含有关浏览器应如何缓存页面的说明。

cheers. 干杯。

Killing the session must be enough. 终止会话必须足够。 When you go back, refresh the page and the user is logged in again, there must be some sort of automatic relogin. 当您返回时,刷新页面,然后用户再次登录,必须进行某种自动重新登录。 This is mostly done using a cookie when the user chooses to check the "remember me" option. 当用户选择检查“记住我”选项时,多数情况下是使用Cookie来完成的。

I would suggest the following: 我建议以下内容:

  1. See if there is a cookie and some sort of re-login mechanism. 查看是否有cookie和某种重新登录机制。 If so, try to logout, clear the cookie, use the back button and see if the problem still exists. 如果是这样,请尝试注销,清除cookie,使用“后退”按钮,查看问题是否仍然存在。 This way, you know the relogin logic kicks in. 这样,您就知道了重新登录逻辑。

  2. If there is no cookie or the above test failed, check the code where you test the session. 如果没有cookie或以上测试失败,请检查用于测试会话的代码。 Maybe you creating it accidentally. 也许是您意外创建的。 For example, when you get the session from an http request, you can control if a new session should be created: 例如,当您从http请求中获取会话时,可以控制是否应创建新会话:

eg 例如

request.getSession(false);

JavaDoc Java文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何区分浏览器后退/前进按钮? - How to distinguish browser back / forward button? 即使更改了哈希值,如何在网页中单击浏览器后退按钮时返回上一页? - How to go back to the previous page when browser back button is clicked in a webpage even when the hash is changed? 阻止用户使用浏览器的“后退”和“前进”按钮 - Stopping the user from using “Back” and “Forward” button of the browser 如何禁用浏览器前进按钮,我有禁用后退脚本...? - how to disable the browser forward button and i have script for disable the back…? 如何通过单击angularjs中的浏览器后退/前进按钮来后退/转发用户的历史记录 - how to back/forward user 's history by clicking the browser back/forward button in angularjs 水平滚动时如何防止浏览器在历史记录中后退/前进? - How to prevent a browser from going back/forward in history when scrolling horizontally? 创建JavaScript小部件时如何管理浏览器的“后退”和“前进”按钮 - How to manage browser “back” and “forward” buttons when creating a javascript widget 禁用地址栏和浏览器的前进和后退按钮 - disable address bar and back and forward button of browser JavaScript和浏览器的后退/前进按钮 - JavaScript and the browser's back/forward button React组件在浏览器后退/前进按钮上中断 - React component breaks on browser back/forward button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM