Question 5

(b) Explain the PHP session and PHP cookie with an example.
<?php
session_start();
session_register('counter');
$_SESSION['counter']= $_SESSION['counter'] + 1;
if ($_SESSION['counter']==1)
{
echo "<h1><center>Welcome! You are a first-time visitor
</center></h1>";
}
else
{
echo "<h1><center>
You have visited this page". $_SESSION['counter'] ."times.Thanks for your visit!</center></h1>";
}
?> <?php setcookie("Username", "Help2Engg");
echo $_COOKIE["Username"];
?>

Make Comments..!!


Oops!! No posts from user.

Download Android App