JavaScript的 - 阿贾克斯 - 就关闭浏览器的JAVA关闭会话关闭浏览器、JavaScript、阿贾克斯、JAVA

2023-09-10 17:54:05 作者:癫狂小青年

在我的web应用程序

1.1I要关闭会话,当用户突然关闭浏览器。

1.1I have to close the session when the user abruptly close the browser.

1.2。当用户试图在新标签中打开 - 用户应该在新的标签被转发到登录页

1.2. When the user tries 'open in a new tab' - The user should be forwarded to the 'login page' in the new tab

我打算使用JavaScript和AJAX的JSPX来实现这一点。

I am planning to use JAVASCRIPT and AJAX to implement this in JSPX.

任何一个可以分享任何样品code来实现他上面我是新来的JavaScript / AJAX?

Can any one share any sample code to implement he above as I am new to javascript/ajax?

推荐答案

这可以通过添加以下META标签在HTML的HEAD来实现。这些标签将清除Cookies当窗口关闭。因此用户需要在下次重新登录。

This can be achieved by adding the following META tags in the HEAD of your HTML. These tags will clear the cookies when the window is closed. hence the user need to relogin the next time.

<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>