Doteasy Tutorial - Scripting - Counters
Cookie Counter: version V1
Do you have hit counter that increases the count every time you refresh your webpage? Are you unwilling to install a bloated multi-file script just to get an accurate hit count? Behold! A dead-simple, miniscule sized, hit counter. A PHP session (cookie) is used to determine if the site has been visited during the browser's session. Basically, you need to close your browser application, reopen it and revisit the webpage to record another hit.


Installation Procedure 
Quick Tips 



The script can be downloaded from here.


The file that you will download is saved in .zip format; this is a compressed bundle containing the files in the distribution. Unzip this archive in a temporary directory on your computer using decompression software.


Input the path to the counter.txt file.

If you are just using the script to update the counter.txt file, and don't need it to print anything in your HTML, set this next variable to the number 0 - otherwise leave it as is.


Start your FTP software and upload all content to your web server preserving the file structure.

Note: Let's assume you install the contents of the counter to /var/www/html/counter/


CHOMD counter.txt to 777

To change file permissions using your FTP client, select the file by clicking on it once on the remote system side and then right-click on the file to bring up the option menu and select CHMOD.


Now you just need to add two lines of code in your webpage. In the very first line of your HTML/PHP page - above all other code, text, headers and tags, add the following:
<?php session_start(); ?>

Then to access the counter, add the following line anywhere in your code:
<?php include("counter.php"); ?>


Congratulations, the installation of Cookie Counter is now complete.


For counter.php file, if you have a working knowledge of PHP and HTML, you can customize what will be output in your HTML. Edit this information in the area listed.

Example:

function output($count) { return "
We have $count hits so far!
";}

If you require additional assistance, please feel free to contact our customer service team: https://www.doteasy.com/ContactUs/SMS/

Top