separator

Take a quiz or make one of your own
Article 4 - Using a Cookie to Override Your Web Hit Counter
What's a Browser Cookie and How Do I Get One? :
It's just a little bit of data that a web site can store on a visitor's machine. Just think about that though, how powerful that is. You can, with the permission of a visitor to your site and a little bit of programming on your server create data which is stored on the computer your visitor has used to go to your site. The potential there is very exciting because it now allows you to anonymously identify your visitors.
Why do I say "anonymously" identify visitors? Because there is really no way to know who they are. When we get into logging site hits in a future article we'll see various things you can know about a visitor; including what browser they're using, operating system, even the time setting on their computer. But you can never know such things as who they are, where they live, or their email address. Unless of course you ask them and they choose to tell you.
Anyhow, if you've implemented the count script on all the pages of your site it'll be easy to set up the cookie we need. You're halfway there now.
So How's It Gonna Work? :
We'll add code to the counting script which checks for a cookie and if it's found, then we won't log that visitor. Why? Because that visitor will be you.

Huh?? There are two operations we need to be able to do for this to work. We have to be able to create (write) and also read a cookie. The count program will just read the cookie, we'll need a separate little program to write the cookie. Since we only want the cookie to reside on our own machine, we'll restrict the permissions after running it.
The modular approach :
If you've been following along in the articles you've decided to either implement your count program using an HTML image tag or SSI. These are two different programs because of the different techniques required. To read our cookie we can just add a similar line of code to either program and we'll be done.... after setting the cookie of course.

separator

© www.thecgibin.com