简体   繁体   English

在php中获取所有当前登录的用户详细信息

[英]Get all currently logged in users details in php

I have a PHP web application where user can login and logout (Session start and cookies are set) and access some pages.我有一个 PHP Web 应用程序,用户可以在其中登录注销(设置会话开始和 cookie)并访问某些页面。 Now, I have to show the list of currently logged in users to the admin.现在,我必须向管理员显示当前登录用户的列表。 But after searching on google I am unable to understand the proper and safe way to do this job.但是在谷歌上搜索后,我无法理解完成这项工作的正确和安全的方法。

Here is currently my thought and its limitations.这是目前我的想法及其局限性。

  1. each time user login, a login record with dateTime will be created每次用户登录时,都会创建一个带有 dateTime 的登录记录
  2. each time user logout, a logout record should be created with dateTime每次用户注销时,应使用 dateTime 创建一个注销记录
  3. Now get currently logged in users by login table enteries现在通过登录表输入获取当前登录的用户

But the problem with the above approach is , it is not necessary that every user logout.但是上述方法问题是,没有必要每个用户都注销。 So I cannot determine the true logged-in users!!!所以我无法确定真正的登录用户!!!

Do there is any smart approach exists that truly inform me about the currently logged in users.??是否有任何智能方法可以真正通知我当前登录的用户。?

You can put a definition on what constitues a logged in user - for isntance if user was active in some period of time.您可以定义登录用户的构成要素 - 例如,如果用户在一段时间内处于活动状态。 Then you can log user actions, and see if given user have any actions logged for given period of time.然后您可以记录用户操作,并查看给定用户是否在给定时间段内记录了任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM