同时防止多次同一用户登录 [英] Prevent same user login from multiple times at the same time

查看:89
本文介绍了同时防止多次同一用户登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同时防止多次同一用户登录。

Prevent same user login from multiple times at the same time.

推荐答案

有多种方法可以做。



首先,您可以在数据库中存储登录用户的标志,并在注销时更新标志

其次,您可以在Application对象中维护登录用户并在注销时更新它/>


现在问题是如果用户没有正确注销或会话超时会发生什么?



您可以选择其他方式。编写代码以在一段时间间隔后更新数据库中的用户状态。此服务将一直告诉数据库用户仍然登录。现在即使用户没有正确关闭浏览器,在固定的时间间隔后,该服务将知道用户不再连接到数据库并将强制完全注销用户。



这种方法肯定会增加你的数据库流量。但可以帮助您防止多次登录!这只是我与您分享的一个想法。
There are multiple ways that you can do.

First you can store flag for logged in users in database and update flag on log out
Second you can maintain logged in users in Application object and update it on log out

Now the question comes what if user doesn't log out properly or the session time out occurs?

There is alternate way you can choose. Write a code to update the user presence in database after some time interval. This service will keep telling database that user is still logged in. Now even if user doesn't close browser properly, after fixed time interval this service will come to know that user is no longer connected to database and will force fully log out the user.

This method will increase your database traffic for sure. But may help you in preventing multiple login! This is just an idea I have shared with you.


这篇关于同时防止多次同一用户登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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