I want to know, is there a way to track how long anyone has been logged into website and then insert it up for each time they have logged on.
In case, user a logs in for 30 minutes, then later comes back and logs in for an hour, then later comes back and logs in for 50 minutes,
Add it up equal 2 hours 20 minutes. Is this possible?
If you're storing the sessions in the db then you could have a field in the session table which would be a timestamp (set when the user logs in) and then when either the user logs out or their session expires, the elapsed time between when they logged on and when they logged off would be calculated and added to the relevant field in the user table
You'll need a cronjob (or equivilant) to do the end-time though, since there isnt a callback on session expiry.
Just because a session expires after 'x' hours doesn't mean that the person was actually on the site all that time. They may have only been there a few seconds and then forgot to log off leaving their session to expire based on settings on the server.
This topic is now closed. New replies are no longer allowed.