PHP script to keep track of the number of times a page is visited by users using cookie

 <?php

    setcookie('count', isset($_COOKIE['count']) ? $_COOKIE['count']++ : 1);

    $visitCount = $_COOKIE['count'];

?>

<html> 

    <head> 

        <title>Count Page Access</title> 

    </head> 

    <body> 

        <?if ($visitCount == 1): ?>

            Welcome! This is the first time you have viewed this page. 

        <?else:?> 

            You have viewed this page <?= $_COOKIE['count'] ?> times. 

        <?endif;?>

    </body> 

</html>

1 comment:

Natasha Romanoff said...

Such a nice and informative blog. Thanks for sharing your knowledge with us. I will share your work with my friends. I have found a QA Consulting Company which is famous for its excellent QA services across the globe. If you need any service related to Qa software testing you can visit.

Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...