Log in

View Full Version : Resolved include() cookies



james438
03-08-2010, 05:23 AM
test.php contains:
<?php
include 'http://www.mysite.com/test2.php';
?>
will produce Array(), but if test.php contains:
<?php
include 'test2.php';
?>works just fine.where test2.php contains:

<?php
print_r($_COOKIE);
?>
Any idea why? Does this have to do with php.ini settings?

djr33
03-08-2010, 10:17 AM
There are several layers to this answer.
In short, using the absolute url is making the include grab a remote file (regardless of whether you are or are not on the same domain at the time).

So when that happens, PHP is the user, not you, and cookies are not available..... among other things.

If you need this to work, it must be on the same server using a relative path.

james438
03-08-2010, 06:58 PM
cool, thanks :)