homepage Welcome to WebmasterWorld Guest from 54.163.70.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Forum User Access Time Tracking
AimyThomas




msg:4493136
 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?

Thanks

 

creeking




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

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

you could look at how they did it.

brotherhood of LAN




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved