I am trying to set a cookie that gives each authorized user access to files in his/her own directory. These directories have the same name as their usernames.
The problem: When I specify a path in the setcookie()function, the cookie does not get set. When I leave the path argument as "/" the cookie is set.
I have tried formatting the path in every way I can imagine and none have worked. Please help!
This is what works:
$cookie_name = "auth";
$cookie_value = "ok";
$cookie_expire = "";
$cookie_domain = "";
setcookie($cookie_name, $cookie_value, $cookie_expire, "/" , $cookie_domain, 0);
These are the path combos that I have tried unsuccessfully ("phptest" is a directory in the domain's root):
"/phptest/$username"
"/phptest/$username/"
"phptest/$username/"
"$username"
"/$username"
"/$username/"
"$username/"
I have also tried each of these combinations with the domain name in front of the path, making it an absolute reference.
I hope this is not confusing. To reiterate -
The problem: When I specify a path in the setcookie()function, the cookie does not get set. When I leave the path argument as "/" the cookie is set.
I am at a loss. Thanks for the help.