如何确保一个用户仅在一台计算机上登录? [英] How to ensure one user login in only one machine?

查看:297
本文介绍了如何确保一个用户仅在一台计算机上登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NET应用程序中,如何确保一个用户仅在一台计算机上登录?

如果用户登录了一台计算机并尝试登录另一台计算机,则应显示一个弹出窗口,提示是否要从其他已登录系统中注销?".如果是,则应终止其他会话并允许其登录当前系统.如何实现呢?请引导我.

In ASP.NET application how to ensure one user login in only one machine?

If the user logged in one machine and trying to login in another machine one pop-up should should shown saying that ''Want to logout from other logged in system?''. If yes, other sessions should be killed and allow to login in the current system. How to achieve this? Please guide me.

推荐答案



据我了解,您只需要一个用户登录实例.
1.您可以在登录表中以IsLoggedin列.
2.使用"Y"之类的标志进行更新,以指示用户何时登录.
3.当用户尝试从其他系统登录时,请选中此标志以及凭据,如果该标志不是"Y",则允许登录.
4.否则,显示消息以注销活动会话.


希望对您有所帮助.
Hi,

As per my understanding you want only one instance of the user login.
1.You can have a column in your login table as IsLoggedin.
2.Update this with a flag like ''Y'' to indicate when the user logs in.
3.When user tries to log in from other system,check this flag along with the credentials and if the flag is not ''Y'', allow login.
4.Else, display message to logout the active session.


Hope this helps.


首先在应用程序启动时创建一个Dictionary集合,然后将其添加到Application(而不是Session)中.

然后获取用户pc的IP地址:

First Create one Dictionary collection in your application startup and add it to Application not Session.

Then Get the Ip Address of users pc:

string ipaddress;
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
    ipaddress = Request.ServerVariables["REMOTE_ADDR"];




用户登录时在应用程序字典"集合中检查用户名.如果用户名和IP地址与存在的用户名和IP地址相同,则继续登录.如果不存在,则添加该对并登录.如果存在用户名,但IP地址不同于当前用户名,则弹出消息,提示用户已登录另一台PC.




When User Login Check for the username in your Applications Dictionary Collection. if Username and Ipaddress is same as exists then proceed with Login. if not exists then add that pair and Login. if username exist but ip address is diffrent than present then popup the message that user already logged in other pc.


这篇关于如何确保一个用户仅在一台计算机上登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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