Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hello i need help with this php code Create a new .php page (name it track.php)

ID: 3706700 • Letter: H

Question

hello i need help with this php code

Create a new .php page (name it track.php) that uses cookies to track the number of times the page has been viewed. If the visitor is looking at the page for the first time, it should display the following message: Welcome! You are a new customer here. If the page has been visited more than once, display: Hello, this is your ## time here (where ## is the number of visits count). Furthermore, if a page has been visited more than once, also display the date and time that the page was last visited on.

Explanation / Answer

ANSWER:

THE BELOW IS THE CODE WITH RESPECT TO THE GIVEN DATA THAT ILLUSTRATES TO CREATE A NEW PHP PAGE AND IT IS AS FOLLOWS;

<?php

$countVisit = 0;

if(isset($_COOKIE['countVisit']))

{

$countVisit = $_COOKIE['countVisit'];

$countVisit ++;

}

if(isset($_COOKIE['lastVisit']))

{

$lastVisit = $_COOKIE['lastVisit'];

}

setcookie('countVisit', $countVisit+1, time()+3600);

setcookie('lastVisit', date("d-m-Y H:i:s"), time()+3600);

if($countVisit == 0)

{

echo "Welcome! You are a new customer here.";

}

else

{

echo "Hello, this is your ".$countVisit." time here.";

echo '<br>';

echo "Last time, you were here ".$lastVisit;

}

Thus by using the above code we can create a new php page.