Wrox Programmer Forums
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2005, 06:03 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default Remember Login

Hi Friends,
I'm new to php,
I want a code for remberlogin....
i think using cookies this can be do.
please help me.


surendran
(Anything is Possible)
__________________
surendran
(Anything is Possible)
http://www.suren.info
http://ssuren.spaces.msn.com
 
Old January 6th, 2005, 08:09 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Hello,

You are using a checkbox in the login form for the visitor to opt for remembering login. Isn't it ? Let chk_remember be the name of that checkbox. The following PHP code will set cookie.

if(isset($HTTP_POST_VARS["chk_remember"]) && strtolower($HTTP_POST_VARS["chk_remember"])=="on")
{
    setcookie("user", $arr_login_details["username"], time()+365*24*60*60);
    setcookie("pass", func_encrypt($arr_login_details["password"]), time()+365*24*60*60);
}

In the above code, $arr_login_details["username"] gives the login name (username) and $arr_login_details["password"] gives the password.

func_encrypt is a function to encrypt password. You may use some simple shifting algorithms to encrypt password. (I am not going into the details of encryption).

To retrieve the username and password in login from, you can use the following PHP code.

$str_username = isset($HTTP_COOKIE_VARS["user"]) ? $HTTP_COOKIE_VARS["user"] : "";

$str_password = isset($HTTP_COOKIE_VARS["pass"]) ? func_decrypt($HTTP_COOKIE_VARS["pass"]) : "";

where func_decrypt is the reverse function of func_encrypt. This function will decrypt the password encrypted by func_encrypt.

Hope this is enough.

Best of luck.





Similar Threads
Thread Thread Starter Forum Replies Last Post
using checkbox in login form remember me next tim avnishraj23 ASP.NET 2.0 Basics 1 December 4th, 2007 08:36 PM
Shading on remember me check box and login backgou mmmctigue BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 July 20th, 2007 09:10 PM
question about login and "remember me next time" hertendreef ASP.NET 2.0 Professional 0 February 14th, 2007 07:29 AM
auto-remember in ie anshul HTML Code Clinic 1 June 22nd, 2004 07:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.