Page hit counter by reading and writing data to fileBy using our reading data to file and writing data to file techniques we have learnt so far by using FSO, we can develop a counter script. This script will store the count value in a text file. Each time the file is opened the script will read the value from the text file and then store it again by increasing it by one. We can call this as page hit counter, which will tell us how many times a page is opened.
This script uses concepts of reading data from file and writing data to file. So before developing this script it is advisable to understand these scripts by reading the respective tutorials.
The page hit counter script we will divide into two parts. First part will read the previously stored count value. Second part will add 1 to the counter value and write the new value to the text file. So while using this script for first time create one simple text file count.txt and store a value 0 inside it.
In the first part after reading the value we have stored the value of the counter in a variable count. Then we will close the file ( in reading mode ) and open the file again in writing mode. Here is the complete script to develop a simple page hit counter.