By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,882 Members | 1,335 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,882 IT Pros & Developers. It's quick & easy.

Adding a "Remember Me" feature

P: n/a
Hello, I have a simple login script. I have the pages

login.php
login_response.php
login_success.php
login_failure.php

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.php page. What must I do to accomplish this?

Thanks for your help, - Dave

Aug 29 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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('Location: http://www.yoursite.com/login_success.php');

Aug 29 '05 #2

P: n/a
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($_COOKIE['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("cookname", $_SESSION['username'], time()+60*60*24*100,
"/");
setcookie("cookpass", $_SESSION['password'], time()+60*60*24*100,
"/");
}

to be checked next time user login.

and then perform rest of the task.

RANI

Aug 30 '05 #3

P: n/a
la***********@zipmail.com wrote:
<snip>
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.php page. What must I do to accomplish this?


1. <news:11**********************@z14g2000cwz.googleg roups.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/

Aug 30 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.