|Setting cookies in php from subdirectory|
Cookies are set when run from root, but not when run in subdirectory
| 4:40 pm on Mar 25, 2003 (gmt 0)|
When i run a php file that sets cookies from the root, the cookies are set.
When i run the same php file that sets cookies but from a subdirectory, the cookies are not set.
i use: setcookie("menuweg", trim($menuweg),time()+360000, "/");
How can i set the cookies from a subdirectory?
| 6:58 pm on Mar 25, 2003 (gmt 0)|
still searching, i found this:
'If you want to send a cookie in a subdirectory that can be read by the whole domain set the path value to "/". '
Why does it not work then?
| 7:12 pm on Mar 25, 2003 (gmt 0)|
are you setting more than one cookie?
| 7:23 pm on Mar 25, 2003 (gmt 0)|
yes, about 6 cookies.
| 7:51 pm on Mar 25, 2003 (gmt 0)|
all for the same domain? There's your problem, multiple cookies for the same domain cause problems. Setting all those cookies they are probably confusing the browser and/or script.
|Consider explode() [php.net] or serialize() [php.net] to set one cookie with multiple names and values |
If you need to track that many vars I would consider using Sessions [php.net]
| 10:02 am on Mar 26, 2003 (gmt 0)|
I've tried to do it with explode and set all values in 1 big cookie, but seems it's just too difficult for me, i just can't get it to work properly.
I did found a workaround, thanks to your advice:
I let the php file in the subdirectory redirect to the root, where the cookies are set, and let the root redirect back to the subdirectory. And it works ok, thanks again.