用户关闭浏览器但未注销时如何终止会话 [英] how to kill the session when user closed the browser without logout

查看:58
本文介绍了用户关闭浏览器但未注销时如何终止会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个aspnet应用程序,因为我正在使用Sessions.如果用户登录到应用程序并单击注销,我将关闭会话.

I am developing one aspnet application in that i am using Sessions. if user login into the application and click on logout here i am closing session.

假设用户未单击注销并关闭浏览器.用户关闭浏览器但未注销时如何终止会话

suppose if the user doesn't click on the logout and he close the browser. how to kill the session when user closed the browser without logout

推荐答案

非常困难的任务:

  • 使用超时非常小的会话/您将到期/

  • use sessions with very smalll timeout /you will have expiration/

使用隐藏的脚本/iframe ping服务器/您将建立连接/

use hidden script/iframe to ping server /you will have connection/

在窗口中处理onunload事件/可以绕过/

handle onunload event in window /can be bypassed/

代码示例:

window.onunload = function ()  
{    
    if((window.event.clientX<0) && (window.event.clientY<0)) {

       window.open("logoff.aspx");                  
    }    
}

这篇关于用户关闭浏览器但未注销时如何终止会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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