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 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Echoing variable from a cookie

    I've known how to do this, but It keeps leaving my memory.

    I set the cookie
    PHP Code:
    <?php
    $yours 
    $_POST['name'];
    setcookie("thename",$yours,time()+31536000);
    echo 
    "The cookie has been set. It will remain for one year unless you delete the cookie. If you delete it, you will have to come back here to reset it!";
    ?>
    and then check for it and echo it
    PHP Code:
    <?php if(isset($_COOKIE['thename'])){
    echo 
    'Welcome'.$_COOKIE['thename'];
    }
    else{
    echo 
    "Welcome!";
    }
    ?>
    It is just echoing Welcome! if when the cookie isset...

    All help is sincerely appreciated...
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    If nothing's being echo'ed, then $yours isn't being set into the cookie

  • #3
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is being set in the cookie
    PHP Code:
    <?php
    $yours 
    $_POST['name'];
    setcookie("thename",$yours,time()+31536000);
    echo 
    "The cookie has been set. It will remain for one year unless you delete the cookie. If you delete it, you will have to come back here to reset it!";
    ?>
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    your best bet is try

    setcookie("thename", "test value", time()+3600);

    then see if anything is output


  •  

    Posting Permissions

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