Cookie Session Php

uses cookies to determine whether or not the visitor has already been counted.
$counterFile = "/home/httpd/html/counter/counter.text";
function displayCounter($counterFile) {
global $counted
$fp = fopen($counterFile,rw);
$num = fgets($fp,5);
if (!$counted) {
$num += 1;
unlink("$counterFile");
exec("echo $num > $counterFile");
}
print "$num";
}
if (!file_exists($counterFile)) {
exec("echo 1 > $counterFile");
}
displayCounter($counterFile);
?>
/* Add the following to the very top of the page you want to count */
?>