Get online time of user


Active member
i would like to get the online time of users, to measure how long they are online, but i dont know how to approach this in a performant way.

i have seen such counters in smf, ipb etc already.

anyone has an idea?
would be much appreciated :)


Active member
yes, have seen that. :D

thought into hooking that, but it is quiet difficult for me to get the exact seconds the user spends online.

still, thank you very much for reminding me about that again, doing to examine the code behind it again, maybe there is something i missed, when i looked at it the first time :)


Well-known member
I don't think you could be 100% accurate and get exact seconds unless you make some kind of ajax call on every page every second which would incrementally increase a value in the db for something like time_online, on the other hand if you were to round the ajax polling to like 45 seconds or a minute you could probably do something with it that wouldn't kill your db with constant writes for every online user every second.


Active member
yes, thats exactly what i worried about.

i really think the best approach is to measure the online timeout or some kind of that.