清除jquery或javascript中的浏览器历史记录以使用户无法单击后退按钮?
我有一个场景,用户单击“注销”并被重定向到主页。但是,当他重定向到主页时,如果单击浏览器的后退按钮,他可以返回到工作区域。我需要阻止他在注销后回到工作区域。有人可以帮忙吗?
I have scenario where the user clicks "log off" and is redirected to the home page. However when he redirects to the homepage if he clicks the back button of the browser he can return to the working area. I need to prevent him from coming back to the working area after he logs off. Can anyone help ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
注销时将会话变量设置为 0,并在页面顶部的脚本标记中检查其值。如果为 0,则停留在登录页面。这将阻止后退按钮进入登录页面。
Make a session variable as 0 upon logout and check for its value in a script tag on the top of the page. If it is 0 stay on the login page. This will prevent back button from entering inside the login page.
您无法阻止用户重新访问之前访问过的 URL,即使他们已经注销也是如此。您的会话管理代码需要管理这种情况。如果用户不再持有有效会话,则不应执行该请求。
如果您试图阻止浏览器在用户注销后显示登录后页面的缓存版本,您可以在登录后可访问的页面上设置一个值为 no-cache 的 HTTP Cache-Control 标头。
There's nothing you can do to prevent a user from revisiting a previously visited URL, even after they have logged out. Your session-management code needs to manage this situation. If the user no longer holds a valid session, the request should not execute.
If you're trying to prevent the browser from displaying a cached version of a post-login page after a user has logged out, you can set an HTTP Cache-Control header with a value of no-cache on pages accessible after login.