在asp.net网站如何$同一用户ID的对$ pvent多次登录? [英] In asp.net site how to prevent multiple logins of same user id?
问题描述
请指导如何使用用户ID为prevent多个用户在同一时间内登录?
Please guide how to prevent multiple user to be logged in at a time using a user id ?
我在网上搜索,发现了一些方法,但不知何故,他们不会在这些情况下工作:
I searched the internet and found some ways but somehow they do not work in these situations:
- 如果在JavaScript的是布劳尔关闭。
- 如果用户不点击注销,直接关闭布劳尔。
请建议我一些方法。
感谢
haansi
推荐答案
有可能是几种可能性。快速反应是:
There could be several possibilities. A quick response is:
-
维护数据库中的标志;在每次登录时输入/输出更新标志。举例来说,在每一个认证请求可以将相应的标志已经成为事实拒绝登录请求。
Maintain a flag in database; upon every login/out update the flag. For instance, upon every authentication request you can reject the login request if the flag is already true.
另外,你可以保持在应用程序用户
对象,并使用。载
来的名单看它是否已经存在。
Alternatively, you can maintain a list of users in the Application
object and use .Contains
to see if it already exists.
- 编辑 -
让我们试着数据库标志选项;并假定你有一个名为方法 StillLoggedIn(用户)
,更新日期/时间和标志。
Lets try the database flag option; and assume that you have a method called StillLoggedIn(User)
that updates the date/time and flag.
所以,当用户登录:
- 的应用程序将会验证用户,并设置标志= 1,和标记日期/时间戳记。
-
有关后续请求时,应用程序会叫
StillLoggedIn(用户)
;
prepare,将不时浏览数据库,时间窗口服务(允许5分钟后说,如果你有10000用户)。该服务会比较数据库日期/时间与当前的日期/时间和标记的旗帜为 0
如果的 currentTime的减lastUsedTime大于,可以说,5分钟的
Prepare a windows service that would browse the database from time to time(lets say after 5 minutes if you have 10000 users). The service would compare the database date/time with the current date/time and mark the flag as 0
if the currentTime minus lastUsedTime is greater than, lets say, 5 minutes.
这可能是除了数据库和窗口服务什么。
It could be anything besides a database and windows service.
这篇关于在asp.net网站如何$同一用户ID的对$ pvent多次登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!