如何在新页面打开时注销[关闭](How to logout when a new page is opened [closed])

所以,我有一个登录网站。

我知道,当用户关闭选项卡时,它会从页面注销。 但是,当用户登录,然后在同一页面上,他会打开一个新页面,例如google(他在url框中键入页面链接并按下回车键)。 Google正在打开,然后当他点击返回按钮时,他会在登录时返回到该页面。如何才能使其注销?

如果有什么不清楚的地方,请发表评论,我会回复。

谢谢你的时间

So, I have a signing in website.

I have it that when the user closes the tab it logouts from the page. But when the user signs in and then on the same page he opens a new page E.g. google ( he types the page link in the url box and presses enter ). Google being opened, and then when he clicks back button he gets back to the page as signed in. How can I make it logout ?

Please if something is not clear, comment it and I will reply.

Thanks for your time

最满意答案

例如,您可以尝试使用javascript window.onbeforeunload事件

window.onbeforeunload = function () { // delete login cookie }

但我不确定它会起作用

You can try use javascript window.onbeforeunload event, for example

window.onbeforeunload = function () { // delete login cookie }

but I am not sure it will work

如何在新页面打开时注销[关闭](How to logout when a new page is opened [closed])

所以,我有一个登录网站。

我知道,当用户关闭选项卡时,它会从页面注销。 但是,当用户登录,然后在同一页面上,他会打开一个新页面,例如google(他在url框中键入页面链接并按下回车键)。 Google正在打开,然后当他点击返回按钮时,他会在登录时返回到该页面。如何才能使其注销?

如果有什么不清楚的地方,请发表评论,我会回复。

谢谢你的时间

So, I have a signing in website.

I have it that when the user closes the tab it logouts from the page. But when the user signs in and then on the same page he opens a new page E.g. google ( he types the page link in the url box and presses enter ). Google being opened, and then when he clicks back button he gets back to the page as signed in. How can I make it logout ?

Please if something is not clear, comment it and I will reply.

Thanks for your time

最满意答案

例如,您可以尝试使用javascript window.onbeforeunload事件

window.onbeforeunload = function () { // delete login cookie }

但我不确定它会起作用

You can try use javascript window.onbeforeunload event, for example

window.onbeforeunload = function () { // delete login cookie }

but I am not sure it will work