This can be done by either cookie or session. You have to make a form for user login and store the info in cookie/session. whenever a user travels around the page you have to count the number of visit until user does not log out. After logout clear the cookie or destroy the session
this link will help you
http://bytes.com/topic/php/insights/712399-making-history-page-big-sites
Feb 14, 2011