Forum Moderators: coopster
<?php
$variable = $HTTP_COOKIE_VARS["cookie"];
?> ..and manage to do it okay. However, I can only do so when viewing the file directly - that is to say, in the format /directory/page.php. My site uses /index.php?d=directory&p=page and the cookie info I've pulled down simply won't display / isn't there when viewing it like this.
I imagine it's something to do with the cookie's path - it's assigned from within a sub-directory, but given the path /, so it can be accessed across the site. Is there anything obvious I'm doing wrong? Any reason for the cookie not to be accessed when doing a php?d=.. etc? Thanks.
If you are truly doing what you are saying, then you are experiencing strange behavior.
Have you tried different browsers to see if the problem is browser-specific?
From the manual:
Note: Microsoft Internet Explorer 4 with Service Pack 1 applied does not correctly deal with cookies that have their path parameter set
Maybe? :)
The concept is correct, so either you have an error in your code, or something else isn't right here.
And unless you are using an older version of PHP, you should use the following, although what you have is still supported:
$variable = $_COOKIE["cookie"];
I recommend the Web Developer Toolbar, by Chris Pederick, and Firefox. It makes checking cookies darn easy.