Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

php cookie's AAAhhhh!!!

Options
  • 26-01-2006 4:20pm
    #1
    Closed Accounts Posts: 521 ✭✭✭


    Hey all, im new to php and am haveing one of those problems....

    It looks and sounds simple which is what is driveing me crasy, All i want to do is set a cookie in a php script and retrieve it before loading a page.

    Tested every line of code surounding this, which work fine...

    php page....
    setcookie("login",$randy,time()+3600,"/project","localhost",0);
    

    Page to be loaded...
    if(!isset($_COOKIE[login])){
    header("Location: http://localhost/project/login.html");
    exit;
    }
    
    This works as i keep geting redirected back to the login page (cookie not set)
    Why? *pulls tuft of hair out*


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    My staple for troubleshooting cookies is to set the cookie with the minimal amount of info.
    So the below will set the cookie for the current host.
    setcookie("login",$randy,time()+3600);
    
    also $_COOKIE[login]? Don't you mean $_COOKIE?


  • Closed Accounts Posts: 521 ✭✭✭EOA_Mushy


    seamus wrote:
    also $_COOKIE[login]? Don't you mean $_COOKIE?

    I did say it was one of those problems.... :rolleyes:

    Cheers


Advertisement