关闭浏览器实际上应清除会话变量的ASP.net会话ID [英] Closing the browser should actually clear the session variables an ASP.net session id

查看:83
本文介绍了关闭浏览器实际上应清除会话变量的ASP.net会话ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.net页面。当我关闭网页我需要清除会话变量。

I have an ASP.net page. When I am closing the webpage I need to clear the session variables.

如何处理此我需要超时维持20分钟。
如果他关闭和登录在20分钟内没有任何多次超时时间

How to to handle this I need to maintain the timeout to 20 minutes. If he closes and login for any number of times in the 20 minutes timed out time

有没有清除ASP.net会话ID的方法可行。

Is there any possiblity for clearing the ASP.net session id

推荐答案

正如其他人的建议,您的会话应该最终超时,但如果你想在超时前关闭会话(例如清理大会话对象),并提供JavaScript来你...

As others have suggested, your session should time out eventually, but if you want to close the session before the timeout (for example to clean up large session objects) AND have javascript available to you...

您可以用 window.onbeforeunload 处理程序做到这一点的职位回到登出页面。

You can do this with an window.onbeforeunload handler that posts back to a sign out page.

function CloseSession( )
{
    location.href = 'SignOut.aspx'; 
}
window.onbeforeunload = CloseSession;

您也可以通过AJAX做到这一点。该SignOut.aspx页面(或任何你正在使用的平台)应该放弃用户的会话。

You could also do it via AJAX. The SignOut.aspx page (or whatever platform you are using) should abandon the user's session.

这篇关于关闭浏览器实际上应清除会话变量的ASP.net会话ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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