注销关闭 [英] Log out in closing

查看:87
本文介绍了注销关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我需要在用户单击(X)按钮关闭浏览器时注销

hi
i need to log out when the user close the explorer by click (X)button

推荐答案

您可以捕获js中的事件,并使用AJAX告诉您的应用它发生了.但是即使那样,我也不是100%相信它,我永远也不会编写依赖于用户注销的代码,对于那些在不知情的情况下设法离开我的网站的用户来说,这意味着超时.

You can capture the event in js and use AJAX to tell your app that it happened. But even then, I would not trust it 100%, I would never write code that relies on the user logging out, I''d impliment a timeout for users who manage to leave my site without me knowing.


是的,

使用js事件,您可以实现它.但是,确实如此,这种方法是不可靠的.因为当网络关闭或关闭电源时可能会发生问题,所以您的会话将持续很长时间.
IIS为会话提供了默认超时20分钟.甚至您都可以在web.config中覆盖它.

Yes,

Using js event you can implement it. But it is also true that, this approach is not reliable. Because problem can be occurs when network goes off or power off then your session will alive for a long time.
IIS provided default timeout 20min for session. Even you can override this in web.config.

<configuration>
    <system.web>
       <sessionState timeout="10"></sessionState>
    </system.web>
</configuration>


这篇关于注销关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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