aimythomas — 2012-09-09T22:52:04-04:00 — #1
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?
spacephoenix — 2012-09-09T23:28:25-04:00 — #2
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
starlion — 2012-09-10T09:00:02-04:00 — #3
You'll need a cronjob (or equivilant) to do the end-time though, since there isnt a callback on session expiry.
felgall — 2012-09-10T17:49:30-04:00 — #4
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.