浏览器上的Sqlserver 2008中的更新表已关闭. [英] Update table in Sqlserver 2008 on browser closed.

查看:121
本文介绍了浏览器上的Sqlserver 2008中的更新表已关闭.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想维护用户在表中的状态,该用户是否为登录用户
在浏览器上单击.如果浏览器被用户定向关闭.在这种情况下,我想更新sql Server 2008中的表. > 窗口.onbeforeunload= SomeFunction;

并调用AJAX函数,但是无法确定它是否可以正常工作.由于HTTP已断开连接,因此无法确定它是否完成了调用.这也可能会杀死Window Explorer中的进程,然后代码将无法运行.他们可能有电源故障或许多其他原因导致无法正常工作.

更好的解决方案是让您的客户端每5分钟发送一次AJAX请求,或以其他方式发送,然后以这种方式更新您的数据库.然后,如果他们尝试再次登录,您可以查看一下上次登录时是否处于活动状态,您可以将其与当前时间进行比较,并了解会话超时,从而可以确定他们是否仍可以登录.

不幸的是,没有做到这一点的完美方法.


I want to maintain the status of a user in a table, that user is loge din or not
on browser click. if browser is directionally closed by user .in this case i want to update the table in sql Server 2008.?

解决方案

You can use

window.onbeforeunload = SomeFunction;

in JS and call an AJAX function but there is no way to be sure that it will work. Since HTTP is disconnected you can''t be sure of it completing the call. The could also kill the process in Window Explorer and then the code would not run. They could have a power failure or many other reasons as to why this would not work.

A better solution is to have your client send an AJAX request every 5 minutes, or whatever, and update your db that way. Then if they try to login again you can look to see if the last time you logged they were active you can compare to the current time and knowing your Session timeout you can determine if they are likely still logged in.

Unfortunately, there is no perfect way of doing this.


这篇关于浏览器上的Sqlserver 2008中的更新表已关闭.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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