Results 1 to 3 of 3

Thread: include() cookies

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default include() cookies

    test.php contains:
    PHP Code:
    <?php
    include 'http://www.mysite.com/test2.php';
    ?>
    will produce Array(), but if test.php contains:
    PHP Code:
    <?php
    include 'test2.php';
    ?>
    works just fine.where test2.php contains:
    PHP Code:
    <?php
    print_r
    ($_COOKIE);
    ?>
    Any idea why? Does this have to do with php.ini settings?
    Last edited by james438; 03-08-2010 at 06:57 PM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    cool, thanks
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •