想要在关闭的选项卡上清除会话变量 [英] want to clear session variables on closed tab

查看:67
本文介绍了想要在关闭的选项卡上清除会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生
我只想知道如何在ASP.NET中关闭的选项卡上清除会话变量.

我遇到的麻烦是,当用户关闭选项卡时,无法终止会话并注销.我使用< bodyönunload="Clear()">检查使用是否关闭网站.如果关闭整个浏览器,效果很好,但是关闭标签页时,效果似乎不太理想.当我再次打开新标签页并查看它时,登录状态仍然有效.我已经在不同的浏览器中尝试过,但是还是一样.那有人有解决方案吗?
谢谢你.

Hello Sir
I just want to know how to clear session variables on closed tab in ASP.NET.

I have trouble that I cannot kill session and log out when the user close the tab. I use the <body önunload="Clear()"> to check if the use close the website. It work great if I close the entire browser, but seem like it doesn''t work well when closing tab. The state of login still effect when I open a new tab again and view it. I already tried in different browsers, but it stills same thing. So does anyone has solution ?
Thank u.

推荐答案

请参考类似的主题:
如何在浏览器关闭时结束用户会话 [ ^ ]
在浏览器上清除会话变量close [在服务器端处理浏览器关闭事件 [ ^ ]
关闭浏览器实际上应该清除会话变量 [此处 [ ^ ]
Please refer similar threads:
How to end user session when browser closed[^]
Clearing Session Variables on browser close[^]
Handle Browser Close Event on the Server-Side[^]
Closing the browser should actually clear the session variables[^]

..and more answers here[^]


检查一下.相同的代码将适用于选项卡关闭或浏览器窗口关闭

如何在浏览器关闭时结束用户会话 [ ^ ]
http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide.all [ http://dotnetfarrukhabbas.wordpress.com/2011/01/26/clear -session-on-browser-close/ [
Check this out. The same code will be applicable for tab close or browser window close

How to end user session when browser closed[^]
http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide.all[^]
http://dotnetfarrukhabbas.wordpress.com/2011/01/26/clear-session-on-browser-close/[^]


尝试一下:
try this:
Session.RemoveAll(); // This Removes All session variables which is used on current application


这篇关于想要在关闭的选项卡上清除会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆