如何prevent用户从多个位置,或在同一台电脑不同的浏览器登录 [英] How to prevent user to login from multiple location or from different browser in same pc
问题描述
我创建,用户的不能尝试多次登录的应用程序。如果一个特定的用户登录时,我的数据库标志值为设置为1 ,这意味着谁拥有相同的用户名和密码可以登录任何其他成员。
I am creating an application where users cannot attempt multiple logins. If a particular user logs in, my database flag value becomes set to 1 that means no other member who has the same username and password can login.
如果用户退出我的数据库标记值设置为0 。这是所有工作正常,但现在我有一个不同的问题是当用户的突然关闭浏览器的没有注销 ,然后自动页面或会话超时数据库标志值应设置为0 。
现在我不知道该怎么做。请给我任何解决方案。
If a user signs out my database flag value is set to 0. That's all working fine but now I have one different problem that is when a user suddenly closes the browser without logout page or session is timeout then automatically the database flag value should be set to 0. Now I don't know how to do it. Please give me any solution.
推荐答案
在你的的Global.asax
文件,你有的Session_OnEnd()
public void Session_OnEnd()
{
// Set flag to 0
}
这将是好的,如果你的的sessionState
设置为 INPROC
(这是默认设置),如果你手动它adjsuted到的StateServer
或 SQL服务器
那么这个事件将被忽略。
This will be okay if your sessionState
is set to INPROC
(Which is the default setting), if you have manually adjsuted it to StateServer
or SQL Server
then this event will be ignored.
在浏览器关闭窗口,你可以做使用<一个href=\"https://developer.mozilla.org/en-US/docs/Web/API/window.onbeforeunload?redirectlocale=en-US&redirectslug=DOM/window.onbeforeunload\"><$c$c>onbeforeunload$c$c>在JavaScript中
When the browser closes the window you can do use onbeforeunload
in JavaScript
window.onbeforeunload = function(e) {
// call an Ajax function to reset the state.
};
这篇关于如何prevent用户从多个位置,或在同一台电脑不同的浏览器登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!