473,722 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Aug 29 '05 #1
3 2411
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');

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($_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

Aug 30 '05 #3
la***********@z ipmail.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.p hp page. What must I do to accomplish this?


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

Aug 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2643
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 values I entered. How do I, in HTML, tell Mozilla and other browsers with this feature to not offer that option? thanks
3
5291
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
3229
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
1768
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 was hoping there is some other method? Thanks, Rob.
2
4952
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 logout the user, the next time i start the browser and go to the application, i don't need to login. That's ok. My questions are:
2
2453
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 on 'logout') when quiting the site, but then, the user looses the benefit of the option "remember me next time" and must login next visit. On the other side, if the user quit the website without logout, at the next
1
3542
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 "Remember Me" check box was not working *at all*. What I mean is when I try to log in with "Remember Me" check box checked, the login fails completely and I'm taken back to the login page (Can't say I left it though :) ). When loggin in with this...
1
1582
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 have to login again manually. If anyone can tell me that how this feature can be implemented. Thanks
1
2336
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 need to redirect the user to either the Login page or the Welcome page depending on whether the user logged in and checked the Remember Me
0
8867
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8740
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9239
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5996
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3208
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2606
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2148
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.