Lab #4
6. Write PHP script to demonstrate passing variables with cookies
first.php
<?php
setcookie("name","Clint Barton", time()+3600,"/","",0);
setcookie("hero_name","Hawkeye", time()+3600,"/","",0);
echo "Cookie set";
?>
second.php
<?php
if(isset($_COOKIE['name']) && isset($_COOKIE['hero_name'])){
echo "Name: ".$_COOKIE['name']."<br/>";
echo "Hero name: ".$_COOKIE['hero_name']."<br/>";
}
?>
Output
first page
second page
Happy Coding :)
0 Comments
Post a Comment