Hi guys I have a simple membership based website where users log in and have their own profiles. I woudl like to be able to tell at any given point in time how many users or rather which users are currently logged into my website.
Its a simple membership based system in php. One way I uderstand it creating a table in a db and storing login details there and session data as well but can this be done in some other way i.e. anyway to find out how many sessions have been started and all the unique users online.
The best way to do this is record the
lastActivityTimefor each user. When they access a page, log the time in their db-record. Once you’re doing that, run a simple query to count all records that have alastActivityTimeless than 5 minutes from theCurrent Time.So rather than asking “how many users are logged in,” you’re asking “how many users were recently active.”