Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Php Programming Code Examples

Php > Cookies Code Examples

Smart Counter - This little script is a plain and simple hit counter that

Smart Counter - This little script is a plain and simple hit counter that uses cookies to determine whether or not the visitor has already been counted. <?php $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 */ <?php if (!$counted) { setcookie("counted",1,time()+600); } ?>