一次一位用户

发布于 2024-09-01 17:48:24 字数 440 浏览 4 评论 0原文

我正在尝试实现只有一个用户可以使用给定的凭据登录。

我在登录时使用此代码检查这一点:

MembershipUser objectUser = Membership.GetUser(Login1.UserName);
    if (objectUser != null)
    {
        boolIsAlreadyLoggedIn = objectUser.IsOnline;
    }

这工作正常。当用户选中“记住我”时,我遇到了问题。 设想 : 1. 如果用户登录时勾选了“记住我”。关闭浏览器。 2. 现在从另一台计算机或另一个浏览器使用相同的凭据登录。他可以登录。 3.但是如果用户再次从Browser-1/machine-1登录,他就可以登录,因为浏览器有持久的cookie。

有人可以建议我如何解决这个问题吗?

提前致谢

I am trying to implement that only one user can login with given credentials.

I check this at the time of login with this code :

MembershipUser objectUser = Membership.GetUser(Login1.UserName);
    if (objectUser != null)
    {
        boolIsAlreadyLoggedIn = objectUser.IsOnline;
    }

This is working fine. I have problem, when a user checked Remember Me.
Scenario :
1. If a user logins with Remember Me checked. Close the browser.
2. Now from another machine or another browser login with same credentials. He can login. 3. But if user login from Browser-1/machine-1 again, he can login, since browser have persistent cookie.

Can anybody suggest me how can I resolve this problem??

Thanks in Advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日情怀 2024-09-08 17:48:24

我假设 cookie 保存有每次登录的会话 ID。只需确保每个用户一次只能与一个会话 ID 关联即可。每次新登录都会用新的会话 ID 替换用户的任何现有会话 ID。当然,任何使用过期会话 ID 的请求都会直接进入“未登录 - 您可能已在其他地方登录”页面。

I assume that the cookie holds a per-login session id. Simply make sure that each user can only be associated with a single session id at a time. Each new login replaces any existing session id for the user with a new one. And of course any request using an expired session id is taken straight to the "not logged in — you may have logged in somewhere else" page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文