Adding a "Remember Me" feature

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    Adding a "Remember Me" feature

    Hello, I have a simple login script. I have the pages

    login.php
    login_response. php
    login_success.p hp
    login_failure.p hp

    What I want to do is have a checkbox on the login.php page where if the
    user checks it and logs in successfully, upon closing the browser and
    returning to the login.php page, they are automatically redirected to
    the login_success.p hp page. What must I do to accomplish this?

    Thanks for your help, - Dave

  • DJ Craig

    #2
    Re: Adding a "Rememb er Me" feature

    On the login_success page, check to see whether they checked "remember
    me". If they did, set either a cookie or a session variable (if your
    sessions are set not to expire too fast) that remembers that the person
    has been authorized. Then on login.php, check for the cookie or
    session variable. If they have it, redirect them to the login_success
    page like this:
    header('Locatio n: http://www.yoursite.co m/login_success.p hp');

    Comment

    • ranii4u@gmail.com

      #3
      Re: Adding a "Rememb er Me" feature

      here

      First of all check user has checked remember me feature checkbox by
      checking
      $_POST['remember'] or whtever name u have given to checkbox

      Second if user checked and u get Post value then set two cookies on the
      user's computer. that contains two important pieces of information: the
      username and the encrypted password. Set cookies expiry time say 100
      days, after which the cookie will be deleted. However, it also gets
      deleted when the user decides to log out

      then whenever user logged in check as above:

      if(isset($_COOK IE['cookname']) && isset($_COOKIE['cookpass'])){
      $_SESSION['username'] = $_COOKIE['cookname'];
      $_SESSION['password'] = $_COOKIE['cookpass'];
      }
      and if he had checked remember me feature then store value as:

      if(isset($_POST['remember'])){
      setcookie("cook name", $_SESSION['username'], time()+60*60*24 *100,
      "/");
      setcookie("cook pass", $_SESSION['password'], time()+60*60*24 *100,
      "/");
      }

      to be checked next time user login.

      and then perform rest of the task.

      RANI

      Comment

      • R. Rajesh Jeba Anbiah

        #4
        Re: Adding a "Rememb er Me" feature

        laredotornado@z ipmail.com wrote:
        <snip>[color=blue]
        > What I want to do is have a checkbox on the login.php page where if the
        > user checks it and logs in successfully, upon closing the browser and
        > returning to the login.php page, they are automatically redirected to
        > the login_success.p hp page. What must I do to accomplish this?[/color]

        1. <news:111099185 5.257652.244240 @z14g2000cwz.go oglegroups.com> (
        http://groups.google.com/group/comp....0fad0eef59415a )
        2. http://www.mt-dev.com/2002/07/creati...-login-script/

        --
        <?php echo 'Just another PHP saint'; ?>
        Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

        Comment

        Working...