PROGRAM
<?php
$value="value is stored in this variable now is retrieved";
setcookie("Testcookie",$value,time()+3600);
?>
<?php
if(isset($_COOKIE['Testcookie']))
{
echo $_COOKIE["Testcookie"];
}
echo "<h2>set cockie in an array</h2>";
setcookie("cockie[three]","cooke three");
setcookie("cockie[two]","cooke two");
setcookie("cockie[one]","cooke one");
if(isset($_COOKIE['cockie']))
{
foreach ($_COOKIE['cockie'] as $name => $value)
{
$name=htmlspecialchars($name);
$value=htmlspecialchars($value);
echo "$name : $value <br />";
}
}
?>
OUTPUT
<?php
$value="value is stored in this variable now is retrieved";
setcookie("Testcookie",$value,time()+3600);
?>
<?php
if(isset($_COOKIE['Testcookie']))
{
echo $_COOKIE["Testcookie"];
}
echo "<h2>set cockie in an array</h2>";
setcookie("cockie[three]","cooke three");
setcookie("cockie[two]","cooke two");
setcookie("cockie[one]","cooke one");
if(isset($_COOKIE['cockie']))
{
foreach ($_COOKIE['cockie'] as $name => $value)
{
$name=htmlspecialchars($name);
$value=htmlspecialchars($value);
echo "$name : $value <br />";
}
}
?>
OUTPUT
No comments:
Post a Comment