473,382 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Adding a "Remember Me" feature

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
3 2395
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Hal Robertson | last post by:
I have created a rather complicated series of html forms for a data entry wizard In my mozilla browser, every time I submit each form along the process, it asks me if I want to remember the...
3
by: TCORDON | last post by:
Can someone give me a sample or point me in the direction of one, on how to implement User "Remember Me" option when logging into a website? TIA
4
by: gencode | last post by:
In asp.net 2.0 there is a Login Control, but I dont want the option to remember the person, is there anyway to hide the"remember me checkbox" I could not see one, Thanks, Ed,
3
by: Rob R. Ainscough | last post by:
I'm looking for some pointers or sample code I can go thru that implements a "Remember Me" feature for a user's login credentials. I'd don't want to use the "login" control provided by VS 2005 and...
2
by: Dan | last post by:
Hi, I use the logon control for logging into the application. When logging and checking the option "remember me next time" and then closing the browser without to press any logout button which...
2
by: André | last post by:
Hi, When clicking on "remember me" when logging, the user asks for not to have to log in next time he visits the site. Now, on one side, i read it is recommended to logout properly (clicking...
1
by: Abdo Haji-Ali | last post by:
Greetings, I'm using the ASP.NET membership model in my site and everything works perfectly, locally. However when I uploaded my site (To my host which is GoDaddy), and ran it remotely the...
1
by: mohini2000 | last post by:
Hi I want to implement a "Remember Me" feature in a website that basically keeps users logged into the website, even after they've closed the browser so that the next time they come, they won't...
1
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hello The site I am working on redirects the user to a "session timed out" page when: - the user's session has expired AND - the user action results in a postback to the server I then...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.