Calculating Total Time Spent by users Online [PHP]

Status
Not open for further replies.

REY619

Ambassador of Buzz
Can someone give tell me a php script or code to calculate the total time spent by a particular user on the site, from the time of registration till now..
The total time will be shown in the profile of the user....
It may involve both php/mysql if it needs.. I have tried everything but it doesnt sems to work..
If u want to see a demo what i am talking about, see here...
Code:
*www.methos.co.za/login.php?loguid=test&logpwd=test
and click on any profile, there the total online time is shown...
Please help.. :( Thanx..
 

QwertyManiac

Commander in Chief
Um, store the session creation time and then the log-out time and that gives you the total time per session. And just keep adding the calculated time to get the total time?
 
OP
R

REY619

Ambassador of Buzz
Hmm yes, thanx, that could do the trick...
But will the time be updated in real time by this method? Cos the total time will be incremented only when the user logs out or the session expires...
 

QwertyManiac

Commander in Chief
Yeah you're right about that, but the only thing you can do closest to real-time monitoring would be to count the time between each page served to the user and set some averages for log-out/expire time.
 
OP
R

REY619

Ambassador of Buzz
I tried doing it, it works, but it only stores the time for a single session. When user logs out, or the session expires, and when the user logs in again, it starts the time again from the starting and the previous online time is lost... :( :(
Tried doing everything but cant figure out the logic..
 
Status
Not open for further replies.
Top Bottom