This is killing me.
When I try to read the value of a cookie from a page that is included from a subdirectory, I get nothing.
Here's my dir structure:
- www.myserver.com/app // the app runs here
- /app/admin // these are admin pages
- /app/admin/adcommon // these are common includes
The cookie is being written successfully using the following code in /admin/login.php:
setcookie ("user_id", $row[0], time()+86400, "", "");
My home page, index.php submits a form to /admin/login.php which writes the cookie and then redirects back to index.php. If I try to read the cookie value directly in index.php, it works fine. (i.e.: echo("$user_id") )
index.php includes /admin/adcommon/navbar.php which attempts to read the cookie value and, depending on the results, displays different HTML. I say attempts because it never reads the value when it is included. If I run the file directly, it reads the cookie and displays the HTML I'm expecting.
If I put index.php, login.php, and navbar.php all in the same directory, everything works gloriously (so I know the read/write is working). I'd rather not do it this way, though.
I can't find ANYTHING after several hours of searching that says "You cannot read a cookie from an included page," so I'd expect this to work.
Argh.
Even a pointer in the right direction would be greatly appreciated. Thanks!