防止多次登录 [英] Prevent multiple login

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

问题描述

大家好.
我想防止在php应用程序中多次登录.
首先,我在access_log表中创建登录状态(活动,非活动)
当用户A登录时,用户状态将设置为活动",如果用户注销,则状态将设置为不活动".当另一个客户端尝试使用仍处于活动状态的同一用户帐户登录时,我将检查access_log表.如果用户仍处于活动状态,则错误登录将发送给用户.
但是发生的问题是,如果用户关闭浏览器.由于用户未单击注销,所以无法更新access_log表中的状态.
有人可以向我提出一些建议.

Hello people.
I want to prevent multiple log in in php application.
Firstly, I create login status(active, Inactive) in access_log table
When user A login the user status will be set to ''active'', and if the user logout the status will be set to ''Inactive''. when another client tries to login using the same user account which is still active, I check the access_log table. if the user still active the error login will be sent to the user.
But the problem occurred is, if the user closes the browser. the status in access_log table cannot be updated because the user didnt click logout.
Can someone suggest me something.

推荐答案

PHP是一种语言,而不是环境或系统.关于阻止登录的内容,您什么都没说,因此您的问题无法回答.
PHP is a language, not an environment or system. You haven''t said anything at all about what you''re trying to prevent login to, so your question is impossible to answer.


由于您的目的是防止多次登录,因此理想的方法是,如果发现会话为活动会话,则在重定向页面中创建注销链接.在此页面中,您可以创建注销过程,例如,假定该人员提供存储在数据库中的某些详细信息,而这些详细信息必须针对数据库进行验证.如果提供的信息正确,则可以继续并销毁另一个活动会话,然后开始一个新的会话.

请注意,您可以在每次登录时将登录会话与唯一标识符(UUID)一起使用,以用于记录目的,并带有布尔状态字段.这将帮助您跟踪记录的会话.

希望它对您有用,如果您觉得有用,请对其进行投票.
Since your aim is to prevent multiple login, the ideal way is to create a logout link in the redirection page if a session is found as active. In this page, you can create a procedure for logout, for instance, the person is supposed to provide certain details stored in the database which have to be validated against the database. If the information provided is correct, you can proceed and destroy the other active session and start a new one.

Note, you can accompany your login sessions with a Unique Identifier (UUID) for each login for logging purposes, together with the boolean status field. This will help you track your logged sessions.

I hope it works for you, if you find this useful, please upvote it.


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

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