如何使用单个帐户限制多次登录。 [英] How to restrict multiple login using a single account.

查看:135
本文介绍了如何使用单个帐户限制多次登录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


在我的项目中有一个要求。如果用户自登录后一次登录

,则不允许其他人使用

相同的用户名进行登录。这是为了避免使用帐户进行多次登录。怎么

这样做?


我有一个想法并实施。


1.当用户登录将用户名,IP,登录时间存储到db。

2.当用户登录时,我会检查表格中是否存在用户名

或不,如果是的话我不会允许用户登录

否则我会允许登录。

3.当他退出时我会删除表中的记录。然后他/

她可以再次登录。


但是有一个问题,用户可以直接关闭浏览器

或右键单击任务栏并关闭它或按Alt + F4。所以

为此我必须抓住Javascript中的内容并触发

注销。


有可能赶上Javascript中的事件,如果是,请

提供给我。


或者是否还有其他任何方法可以限制多次登录使用单一

账号。


提前付款。


Shankhar

Hi all,

In my project there is a requirement. If a user logged in at a time
since he/she logged out others are not allowed to loggin using the
same user name. That is to avoid multiple logins using a account. How
to do this?

I had got a idea and implemented.

1. When a user logs in storing the username, ip, login time to db.
2. When a User logs in i''ll check the table whether the username
exists in the table or not if yes i''ll not allow the user to login
else i''ll allow to loggin.
3. When he logs out i''ll delete the record from the table. Then he/
she can login again.

But there is a problem in this the user can close the browser directly
or right click in the taskbar and close it or by pressing Alt + F4. So
for this i have to catch the things in Javascript and trigger the
logout.

Is is possible to catch the events in Javascript, if yes please
provide me.

Or Is there any other method to restrict multiple login using single
account.

Thanx in advance.

Shankhar

推荐答案

shankhar写道:
shankhar wrote:

大家好,


在我的项目中有一个要求。如果用户自登录后一次登录

,则不允许其他人使用

相同的用户名进行登录。这是为了避免使用帐户进行多次登录。怎么

这样做?


我有一个想法并实施。


1.当用户登录将用户名,IP,登录时间存储到db。

2.当用户登录时,我会检查表格中是否存在用户名

或不,如果是的话我不会允许用户登录

否则我会允许登录。

3.当他退出时我会删除表中的记录。然后他/

她可以再次登录。


但是有一个问题,用户可以直接关闭浏览器

或右键单击任务栏并关闭它或按Alt + F4。所以

为此我必须抓住Javascript中的内容并触发

注销。


有可能赶上Javascript中的事件,如果是,请

提供给我。


或者是否还有其他任何方法可以限制多次登录使用单一

账户。


提前付款。


Shankhar
Hi all,

In my project there is a requirement. If a user logged in at a time
since he/she logged out others are not allowed to loggin using the
same user name. That is to avoid multiple logins using a account. How
to do this?

I had got a idea and implemented.

1. When a user logs in storing the username, ip, login time to db.
2. When a User logs in i''ll check the table whether the username
exists in the table or not if yes i''ll not allow the user to login
else i''ll allow to loggin.
3. When he logs out i''ll delete the record from the table. Then he/
she can login again.

But there is a problem in this the user can close the browser directly
or right click in the taskbar and close it or by pressing Alt + F4. So
for this i have to catch the things in Javascript and trigger the
logout.

Is is possible to catch the events in Javascript, if yes please
provide me.

Or Is there any other method to restrict multiple login using single
account.

Thanx in advance.

Shankhar



有''无法判断用户是否关闭了他的浏览器。或者关闭他的电脑,从他的网络或任何一些东西上拔掉电源。


您可以使用短暂的超时,即15分钟,以及如果他们在那个时间段内没有做什么,那么他们的会话就会被删除。


但是我最喜欢的一个是如果一个人登录当另一个

一个人正在使用该帐户时,第一个帐户会自动退出。

这会非常烦人 - 他们很快就会停止分享他们的帐户
与他人联系。


-

================== br />
删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================

There''s no way to tell if the user closed his browser. Or turned off
his computer, unplugged from his network or any of a number of things.

You can use a short timeout, i.e. 15 minutes, and if they don''t do
something in that time period their session gets deleted.

But one of the ones I like best is if one person logs on while another
one is using that account, the first one is logged out automatically.
It gets to be very annoying - and they soon stop sharing their account
info with others.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


当用户登录或点击其帐户中的选项时,如果有人试图登录到同一个

当前时间存储在数据库中>
帐户,检查他们最后一次行动是否在最后15分钟b
分钟。如果是,拒绝访问。当用户点击注销时,重置

数据库中的时间。


这样,如果有人关闭了他们的浏览器,那么他们必须做的就是

等待15分钟,当用户正在积极使用他们的

帐户时,其他任何人都无法登录。

When a user logs in or clicks an option in their account, store the
current time in a database, if someone tries to log on to the same
account, check to see if the last action they made was in the last 15
minutes. If it is, deny access. When the user clicks on logout, reset
the time in the database.

this way, if someone does close their browser then all they have to do
is wait 15 minutes, and whilst the user is actively using their
account, no-one else will be able to log in.


Jerry有正确的想法。


用户会话超时很好 - 但可以反击

高效。

如果其他人登录,用户退出是一个很好的方式

,因为它提醒用户其他人可以访问他们的帐户。


暴雪做到了这一点:)


5月22日凌晨3点13分,Jerry Stuckle< jstuck ... @ attglobal.netwrote:
Jerry has the right idea.

Having the user session time out is fine - but can be counter
productive.
Having the user logged out if someone else logs in is a good way to go
since it alerts the user someone else has access to their account.

Blizzard does that :)

On May 22, 3:13 am, Jerry Stuckle <jstuck...@attglobal.netwrote:

shankhar写道:
shankhar wrote:

大家好,
Hi all,


在我的项目中有一项要求。如果用户自登录后一次登录

,则不允许其他人使用

相同的用户名进行登录。这是为了避免使用帐户进行多次登录。怎么

这样做?
In my project there is a requirement. If a user logged in at a time
since he/she logged out others are not allowed to loggin using the
same user name. That is to avoid multiple logins using a account. How
to do this?


我有一个想法并已实施。
I had got a idea and implemented.


1.当用户登录时存储用户名,ip,登录时间到db。

2.当用户登录我会检查表格中是否存在用户名

,如果是,我将不允许用户登录

else i'将允许登录。

3.当他退出时我会删除表中的记录。然后他/

她可以再次登录。
1. When a user logs in storing the username, ip, login time to db.
2. When a User logs in i''ll check the table whether the username
exists in the table or not if yes i''ll not allow the user to login
else i''ll allow to loggin.
3. When he logs out i''ll delete the record from the table. Then he/
she can login again.


但是有一个问题,用户可以直接关闭浏览器

或右键单击任务栏并关闭它或按Alt + F4。所以

为此我必须抓住Javascript中的内容并触发

注销。
But there is a problem in this the user can close the browser directly
or right click in the taskbar and close it or by pressing Alt + F4. So
for this i have to catch the things in Javascript and trigger the
logout.


是否有可能在Javascript中捕获事件,如果是,请

提供给我。
Is is possible to catch the events in Javascript, if yes please
provide me.


或者是否有任何其他方法可以使用单个

帐户限制多次登录。
Or Is there any other method to restrict multiple login using single
account.


提前完成。
Thanx in advance.


Shankhar
Shankhar



没有办法判断用户是否关闭了他的浏览器。或者关闭他的电脑,从他的网络或任何一些东西上拔掉电源。


您可以使用短暂的超时,即15分钟,以及如果他们在那个时间段内没有做什么,那么他们的会话就会被删除。


但是我最喜欢的一个是如果一个人登录当另一个

一个人正在使用该帐户时,第一个帐户会自动退出。

这会非常烦人 - 他们很快就会停止分享他们的帐户
与他人联系。


-

================== br />
删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司

jstuck ... @ attglobal.net

==================


There''s no way to tell if the user closed his browser. Or turned off
his computer, unplugged from his network or any of a number of things.

You can use a short timeout, i.e. 15 minutes, and if they don''t do
something in that time period their session gets deleted.

But one of the ones I like best is if one person logs on while another
one is using that account, the first one is logged out automatically.
It gets to be very annoying - and they soon stop sharing their account
info with others.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================



这篇关于如何使用单个帐户限制多次登录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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