This code in http://www.w3schools.com/php/showphp.asp?filename=demo_cookie5 returns
"Cookies are enabled"
In my localhost it returns
"Cookies are disabled"
This code in http://www.w3schools.com/php/showphp.asp?filename=demo_cookie5 returns
"Cookies are enabled"
In my localhost it returns
"Cookies are disabled"
This is just bad example.
Use isset($_COOKIE)
instead of count($_COOKIE) > 0
.
Also, use print_r($_COOKIE)
to see its structure.
This isn't a problem, it's a security configuration in your browser.
You only have to allow cookies in your browser.
If you have enabled cookies in your browser then something simple like this should do the job:
if(isset($_COOKIE['name']))
{
$var = $_COOKIE['name'];
echo "Cookie was set". "<br>";
echo "Welcome back! <br> Your name: ". $var. "<br>";
}