Page 1 of 1

hit counter

Posted: Sat Jul 31, 2010 8:52 am
by tobie montana
Heya, i wonder if someone could help me make a kind of advanced hit counter, It should only count a visit from 1 computer each 24/h so if i visit the site several times with my computer 1 day it will only count 1 time that day. Then if you are the 100th visitor you should come to another site. Thanks in advance // Tobie Montana

Re: hit counter

Posted: Sat Jul 31, 2010 11:35 am
by califdon
tobie montana wrote:Heya, i wonder if someone could help me make a kind of advanced hit counter, It should only count a visit from 1 computer each 24/h so if i visit the site several times with my computer 1 day it will only count 1 time that day. Then if you are the 100th visitor you should come to another site. Thanks in advance // Tobie Montana
What kind of help are you asking for? If you want someone to write it for you, good luck. If you just want some tips about the logic, maybe I can help. Where do you want to store the visits, in cookies on the visitor's computer or in a database on the server? Each has its own advantages and disadvantages. If you want to use cookies, the logic would be something like this:

Code: Select all

Is there a cookie on the user's computer? If no, this is visit #1, set cookie; if yes, is the cookie date today's date? If no, increment the visit count, store back to cookie; if yes, ignore.
If this is visit #100, do whatever.
If you want to use a database, the logic would be something like:

Code: Select all

Query your database: is there a record for this user (or IP address)? If no, this is visit #1, insert record; if yes, is the date today's date? if no, increment the visit count, update record; if yes, ignore.
If this is visit #100, do whatever.