简体   繁体   中英

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. 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
  2. each time user logout, a logout record should be created with 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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