|
|
|
|
![]() ![]() |
Jul 7 2005, 01:22 AM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 407 Joined: 13-December 04 Member No.: 2,696 |
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. |
|
|
|
Jul 7 2005, 02:50 AM
Post
#2
|
|
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,161 Joined: 9-May 05 From: Brisbane, QLD Member No.: 6,818 |
You should Google 'session variables'.
|
|
|
|
Jul 19 2005, 05:28 AM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 351 Joined: 19-October 04 From: India Member No.: 1,824 |
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. |
|
|
|
Oct 10 2005, 04:21 PM
Post
#4
|
|
|
Newbie [Level 3] ![]() ![]() ![]() Group: Members Posts: 42 Joined: 8-October 05 From: Haarlem, The Netherlands Member No.: 12,672 |
I started a class that should mesure hits, visits, etc per day (in a servlet) today...
I will post the result soon! |
|
|
|
Oct 19 2005, 12:36 AM
Post
#5
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 73 Joined: 21-September 05 Member No.: 12,113 |
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. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th September 2008 - 05:23 PM |