You're not being very clear so I am going to try an answer your question as best as I can
If you are trying to put a counter on a webpage, I wouldn't. Counters have not been "in style" for a long time and IMO look "amateurish" on a page.
If you want to track visitors for reporting. Cookies have a couple of problems (well truthfully all methods of tracking visitors have problems, but that's a different problem). Cookies can be turned off or cookies can be deleted before expiration. You also have to write special handling to track visitors by cookies.
I would recommend getting a logfile analysis program to get visitor counts. They should give you a reasonable unique visitor count (based on IP). Of course this has a couple of flaws. Several people behind a NAT'd firewall will show up as 1 visitor and people who don't have static IP's (dial-up users will generally get a new IP every time and Cable users will get a new IP every month or so).
Check out AWStats or Analog, both are good
grep
| XP matters not. Look at me. Judge me by my XP, do you? |
| [reply] |
Are you sure you want to save this information in cookies? If you really care about this data, it's probably better not to save it in a cookie since any user can blow their cookies away at any time. If you don't really care about this data, then perhaps it's not really worth saving at all.
However, if you really want to do it, and you're doing it via CGI, look at CGI.pm, specifically the stuff on HTTP cookies. | [reply] |
You've got two sources of information to identify the client side, cookies and IP addresses (and port, to cover NATed connections). As the previous posters have indicated, neither method is all that reliable. How about using both. Store the current IP address in a cookie, and check it each time to see if the IP in the cookie is the same as the current IP.
If you need reliable identification of repeat clients, you can than limit what you track to the cases where the cookie IP and the current IP agree, and throw out the others as uncertain IDs. If high reliability isn't a goal, you can use some combination of the two, and accept the errors. You might even be able to track users through a succession of IP addresses, you just couldn't do it reliably. | [reply] |
| [reply] |