How to set and check for a cookie?

Discussion in 'PHP' started by Airwalk Enterprise, Inc, Mar 24, 2011.

  1. Airwalk Enterprise, Inc

    Airwalk Enterprise, Inc Peon

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    I don't really want to indulge in something else I know nothing about, and also like I said, the host confirmed that php, sessions and cookies were working fine. It must be something else in my code that I'm doing wrong :(
     
    Airwalk Enterprise, Inc, Mar 24, 2011 IP
  2. Airwalk Enterprise, Inc

    Airwalk Enterprise, Inc Peon

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #22
    I've tried taking the most basic cookie function from w3 schools andplacing it in random places, and even where setcookie is in the html head section

    nada

    <?php
    $expire=time()+60*60*24*30;
    setcookie("user", "Alex Porter", $expire);
    ?>

    <?php
    // Print a cookie
    echo $_COOKIE["user"];

    // A way to view all cookies
    print_r($_COOKIE);
    ?>

    print_r returns a whole mess of crap like before:(
     
    Airwalk Enterprise, Inc, Mar 24, 2011 IP
  3. Airwalk Enterprise, Inc

    Airwalk Enterprise, Inc Peon

    Messages:
    126
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    Tested on another domain, still the same

    however they were the same host
     
    Airwalk Enterprise, Inc, Mar 24, 2011 IP
  4. bledileka

    bledileka Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #24
    try using another web browser, maybe your browser settings does not allow cookies :p it may be! If this wont resolve then its for sure your web server configurations.
     
    bledileka, Mar 24, 2011 IP