I want to make the cookie accessible for the entire root folder, how can I do it ??
<?php
$value="test";
setcookie("test",$value, time()+3600, '/', NULL, 0 );
if($_COOKIE['test']=="test")
{
echo 'ok';
}
else
{
echo 'not ok';
}
It works only for the particular folder where the cookie is declared ,
ie., localhost\proj\app\views\settings\client*
but I want to make accessible on the folder
localhost\proj\app\views\*
How can I do this ?
Cookies can be restricted by allowing only sub domain access,to make cookie available for all set its domain to *.domain.com.
What worked for me is
setcookie(cookieName, cookieValue, time()+31557600, '/', '.domain.com');
When I tried with wildcard it didn't work, but as per official php.net documentation
http://php.net/manual/en/function.session-set-cookie-params.php
You just need to put a single slash as the path and .domainname.extension as the domain.