Step 1: Create the php file that verify the username and password.
Step2: If the username and password is correct then check whether the cookie for the user is
already get or not.
already get or not.
Step3: If the cookie is set then retrieve the value from the cookie and store it
$c=$_cookie[$user]+1
setcookie($user_$c, time()+60*60*24*120);
Step4: If the cookie is not set then set the cookie with the default value.
Step5: If the staff wants to view the number of visit.
Step6: Get the registration number.
Step7: Retrieve the value from the cookie
$c=$_COOKIE[user]+1.
Step8: Display the number of visits.
Step9: Run the program in the browser.
PROGRAM
<?php
include("config.php");
if (!isset($_COOKIE[$nam]))
{
setcookie("nam",1,time()+60*60*24*30);
echo "<br><br>It appears that this is your first visit!";
}
else {
$n=$_COOKIE["nam"];
$n1=$n+1;
setcookie("nam",$n1,time()+60*60*24*30);
$n1=$_COOKIE["nam"];
echo "You have visited ".$_COOKIE["nam"]." times!";
}
?>
0 comments:
Post a Comment