Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    New Zealand
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disappearing Cookie

    Hi there, I am having trouble accessing a cookie on different pages of my site. I have print_r($_COOKIE); at the top of two different pages, one returns the cookie contents, the other returns Array ( ).

    I set the cookie is set at:
    http://www.domain.com/login/index.php and print_r($_COOKIE); returns the cookie value once the user is logged in and the cookie is set.

    On the page:
    http://www.domain.com/activities/activity1.php the print_r($_COOKIE); request returns an empty array: Array ( ).

    Note, I can surf the site and then go back to http://www.domain.com/login/ and it will still show the cookie contents, it only seems to "disappear" when I am on certain pages.

    Are there any obvious causes for this?

    Thanks
    Last edited by Candrias77; 05-20-2004 at 11:50 PM. Reason: Spelling error.
    eTheory - the theory of revolution

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    New Zealand
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solved

    Quite simple in end.

    The problem was that the cookie was registered from a sub-directory on the site but I had left the directory attribute of setcookie() as empty, there for it was only available to files within that directory (and it's sub-directories).

    Correct code was to set the cookie with: setcookie('cookiename', $login_value, 0, '/');
    eTheory - the theory of revolution


  •  

    Posting Permissions

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