If you put the counter on two separate pages in the same path (e.g. http://domain.com/page1.php and http://domain.com/page2.php), then it shares the count between pages. If I view page1.php 10 times, then go to page2.php, it shows me that I've visited it 11 times, even though it's my first time.
This is a very simple script to show how a cookie (persistent data) can keep track of how many times a user visits a single web page.
For the very reason that the script uses a cookie (so that it can remember the visit count for a long time), means that if two different pages reference the same script (use the same cookie), the count will be inaccurate.
It was assumed that you would rename the cookie for each page you wanted to keep a count for. For example: you home page counter would be $_COOKIE["home"], your contact page would be $_COOKIE["contact"], etc.
I'm sorry this wasn't obvious, but the script works as intended, and should meet your needs once you know how to use it.
For the very reason that the script uses a cookie (so that it can remember the visit count for a long time), means that if two different pages reference the same script (use the same cookie), the count will be inaccurate.
It was assumed that you would rename the cookie for each page you wanted to keep a count for. For example: you home page counter would be $_COOKIE["home"], your contact page would be $_COOKIE["contact"], etc.
I'm sorry this wasn't obvious, but the script works as intended, and should meet your needs once you know how to use it.