Number Of Users Logged In

3 posts by 3 authors in: Forums > CMS Builder
Last Post: January 23, 2013   (RSS)

Hi,

I haven't tried this, but the last Login date field lastLoginDate in user accounts seems to be updated each time a logged in user accesses the site.

If that's true, and you set a limit of say 5 minutes of inactivity as indicating logged off, then you could count the number of user records who have a last log in date of less than 5 minutes ago as the number of logged in users. I don't know how you would make that a dynamic number but you could reload every 30 seconds or so.

Try a google search for "number of logged in users PHP" for some more specific ideas.

Hope that makes sense.

Good luck and please post your findings

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi nmsinc,

If your familiar with creating CMS Builder plugins, this would be something that would be fairly simple to implement. You could create a new date field in the accounts section called something like 'last_activity'. Then use the section_init hook to detect when a user has loaded a page in CMS Builder, and update their 'last activity' field with the current date and time.

Then you could use Jerry's suggestion of checking how many users 'last activity' fields have been updated in the last five minutes. You could do this using the mysql_select function.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com