Re: $_COOKIE and include() or require()
| From: | Chris Wesley | Date: | Mon, 23 Dec 2002 08:22:56 +0000 |
| Subject: | Re: $_COOKIE and include() or require() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129151@lists.php.net to get a copy of this message | ||
On Mon, 23 Dec 2002, Luke Sneeringer wrote:
> However, then in the script I have a require tag (essentially like
> require('http://www.mydomain.com/common.php')) line.
> I call this line,
> and within that file (same domain) the $_COOKIE[] array as well as
> variables such as $cookiename are all blank. I cannot figure out for the
> life of me why this is occuring.
The most likely scenario is that common.php is being processed by the web
server & PHP before being included into your code. This would be causing
a second HTTP request from your web server to your web server for the
included code ... there are no cookies on the HTTP request for the
included code, /and/ the variables available to the parent are not
available to the included code. You effectivly get the output of
common.php, not included code.
Try this:
- copy common.php to common.inc (or some other extension that your web
server is not configured to hand off to be parsed by PHP).
- in the parent code, include() the common.inc URL instead of the
common.php URL.
Let us know if that helps or not.
g.luck,
~Chris