Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

php cookie's AAAhhhh!!!

  • 26-01-2006 04: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, Registered Users 2 Posts: 68,173 ✭✭✭✭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