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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remember Me - Cookie

    Hi All,

    I'm trying to do the usual "Remember Me" checkbox on my login page.

    I have found bit and pieces at different places but I'm still stuck. I either have a problem to read the cookie, or detecting if there is one, etc.

    Anybody has a sample code doing that?

    Thanks in advance,

    Pat

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <?php

    // check if cookie exists
    if(isset($_COOKIE['rememberme'])){
      
    // login user
    }else{
     
    // show html form
    }
    ?>
    PHP Code:
    <?php

    // process login form
    // usual form validation etc here
    // DON'T PRINT ANYTHING OUT TO THE PAGE BEFORE YOU SET A COOKIE, OR YOU'LL GET ERRORS. 

    setCookie("rememberme",$username,time()+36000);
    // cookie set, get value of cookie by echoing $_COOKIE['rememberme']
    ?>
    http://php.net/setcookie
    Last edited by Nightfire; 09-25-2003 at 08:54 PM.


  •  

    Posting Permissions

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