Very very strange problem with setcookie()

Discussion in 'PHP' started by SuperDennis, Jul 8, 2009.

  1. #1
    Hello,

    Could someone, please, help me?

    I am trying to set cookie in a folder to be available to that folder and ALL subfolders, but it doesn't work and nothing helps, I tried a lot of variations. Here is what documentation says should work for me:

    $_COOKIE['signed_in'] = true;
    setcookie("signed_in", $_COOKIE['signed_in'], 0, '/WEB/portal/', 'localhost');
    PHP:
    But when I set this cookie from http://localhost/WEB/portal/ it isn't set at all - when I reload the page it disappears. When I use the following code, the cookie is set in current folder ONLY, and doesn't work for neither parent folders nor subfolders:

    $_COOKIE['signed_in'] = true;
    setcookie("signed_in", $_COOKIE['signed_in'], 0);
    PHP:
    Please, help me.. I need my cookie work both in http://localhost/WEB/portal/ and http://localhost/WEB/portal/tags/computers/ and so similar.
     
    SuperDennis, Jul 8, 2009 IP
  2. SuperDennis

    SuperDennis Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Also, forgot to say the following code also doesn't set a cookie at all (I mean I can't see it from the script):

    $_COOKIE['signed_in'] = true;
    setcookie("signed_in", $_COOKIE['signed_in'], 0, '/', 'localhost');
    PHP:
    while it should work for all the domain, it doesn't, and that is veery strange.
     
    SuperDennis, Jul 8, 2009 IP
  3. SuperDennis

    SuperDennis Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    any ideas?
     
    SuperDennis, Jul 13, 2009 IP
  4. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Instead of $_COOKIE['signed_in'] = true;

    Can you please try $_COOKIE['signed_in'] = "yes"; and if it sets the cookie
     
    HivelocityDD, Jul 14, 2009 IP
  5. webaddict.info

    webaddict.info Banned

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    does your browser accept cookies?
     
    webaddict.info, Jul 14, 2009 IP