如何允许一个用户允许一个会话 [英] how to allow one user to allow one session

查看:107
本文介绍了如何允许一个用户允许一个会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我

我希望针对一个用户ID进行一次会话。

在新登录时我将UserId添加到应用程序Sate中存储的字符串列表。如果用户存在于列表中,则显示消息用户已登录,如果用户不在列表中,则允许用户访问应用程序。

如果用户使用应用程序的注销功能,则此功能正常。

如果用户关闭浏览器并再次尝试登录,它也会获得用户已登录的相同消息

解决方案

没有告诉浏览器已关闭的可靠方法 - 您可以处理Javascript onbeforeunload和unload事件,但是......第一个并不是所有浏览器都支持,后者发生在用户同时使用后退和前进按钮时。



如果用户关闭电源,它们都不会发生!



您最好的解决方案可能是在数据库中设置登录计时器当用户做任何事情时约会它。当他尝试登录时,你检查计时器并拒绝它是否仍然是最新的。


看到这些..

http://stackoverflow.com/questions/2922502/limit-only-one-session-per- user-in-asp-net [ ^ ]

http://www.sprklab.com/notes/5-how-to-allow-only-one-user-per-account-in-aspnet [ ^ ]

Can any one help me
I want one session against one userID.
At the time of new login I am adding UserId to List of strings Stored in application Sate.If user exists in the list then message is displayed user is already logged in and if user is not in the list user is allowed to access application.
This goes OK if user uses the Logout Functionality of application.
If user closes the browser and tries to Login again it also gets the same message user is already logged in

解决方案

There is no reliable way to tell that the browser is closed - you can handle the Javascript onbeforeunload and unload events, but...the first isn't supported by all browsers, and the later occurs when the user uses the back and forward buttons as well.

And neither of them occur if the user turns the power off!

Your best solution is probably to set a login timer in your DB and update it when the user does anything. When he tries to log in, you check the timer and refuse if it is still current.


see these..
http://stackoverflow.com/questions/2922502/limit-only-one-session-per-user-in-asp-net[^]
http://www.sprklab.com/notes/5-how-to-allow-only-one-user-per-account-in-aspnet[^]


这篇关于如何允许一个用户允许一个会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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