kvarnerexpress 0 Report post Posted July 7, 2005 Hi all,I want to keep track of how often certain pages are visited but I don't want to have it such that someone can keep refreshing a page to increment the number of times a page is visited.What would be the best way to keep track of visiters on my site so I can know what pages they are going to.I'm going to database this data so I can generate a little "most visited" list for my page of, say, the top 5 most visited pages.I imagine using a cookie or something but I would like to have a time frame on it, such that, if the same person re-visits the site after, x amount of time (an hour/day), the page 'hit' will increment. Share this post Link to post Share on other sites
Tyssen 0 Report post Posted July 7, 2005 You should Google 'session variables'. Share this post Link to post Share on other sites
cse-icons 0 Report post Posted July 19, 2005 hi kvarnerexpress,yeah you can use session in this case.When someone visits the page, use the session id to identify which session is requesting the page and put it in a hashmap with the count. and/or time. Now when the page is requested again. check whether it is from the same session, if it is, then compare the time of last visit and update the count if sufficient time has elapsed else just serve the page.You need to run a cleanup routine at regular intervals so that the sessions in the hashmap that have not been used for a long time are removed so as to free up the space..Cheers. Share this post Link to post Share on other sites
vitrus 0 Report post Posted October 10, 2005 I started a class that should mesure hits, visits, etc per day (in a servlet) today...I will post the result soon! Share this post Link to post Share on other sites
dul 0 Report post Posted October 19, 2005 Use session variables. But good idea is save the session variable in a database. (such as IP address etc..). After that you can control you counter as much as you want. Share this post Link to post Share on other sites