I have a folder test in my localhost.
In file test/cookie/a.php:
<?php setcookie('email','abc@gmail.com',time()+3600);?>
In file test/cookie/b.php
<?php echo $_COOKIE['email'] ?>
A file name test/x.php, I write code
<?php
echo $_COOKIE['email'];
?>
first, I run file a.php, after that I run b.php, and x.php. But only file a.php display abc@gmail.com, file x.php show error:
Notice: Undefined index: email in D:\xampp\htdocs\test\x.php on line 2.
Any idea?
User the form optional
pathparamter for set cookie'/'to set the cookie for whole domain.Now you will have email in other files too. Check documentation