Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Forum User Access Time Tracking



3:48 am on Sep 10, 2012 (gmt 0)

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?



4:41 am on Sep 10, 2012 (gmt 0)

5+ Year Member

I think SMF forum software has this feature, or used to.

you could look at how they did it.

brotherhood of LAN

5:58 am on Sep 10, 2012 (gmt 0)

WebmasterWorld Administrator brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

You can easily track when someone logs in, the tricky part is knowing how long they were surfing your site. On the server-side you may want to just log the 'last page view time' with PHP or similar, but it won't take into account how long they viewed the last page they were on.

The easy but wasteful way is to periodically poll your server with javascript , that will indicate that the user still has your forum page in their browser tab. You can set this up using Javascripts setTimeout function to periodically fetch a URL from your server.

A more efficient way would be something like HTML5 Web sockets [html5demos.com] which avoids the overhead of all the HTTP headers you send, because basically you're only after a boolean value, is the visitor still there, or not.

One other quite simple way is to use the unload() function in javascript that'll initiate when someone leaves the page... but won't give you any information at all between the page loading and them leaving the page... and will also not show anything for people who shut their browser down rather than just visit another page.

p.s. it is more a client-side question rather than server-side... so you may get better answers in the javascript/browser-side forums.

Featured Threads

Hot Threads This Week

Hot Threads This Month