[thelist] Remember Me Option -Cookies

Paul Bennett paul at teltest.com
Tue Feb 11 16:05:01 CST 2003


Mark Joslyn wrote:

>I am trying to add a "Remember Me" functionality to my login. I see these
>all over the place - even on Evolt.org.
>
>The cookie section of the PHP manual is not helping me so far, or maybe I am
>too new to decipher the solution from the information suggested.
>
>I am having trouble tying the code to the "Remember Me" checkbox. Also, when
>do I write the cookie,
>
when you see the checbox value is "checked"
eg
<?
if($HTTP_POST_VARS["checkboxName"] == "checked")
    {
   setcookie ("TestCookie", $value,time()+3600); /* expire in 1 hour */
    }

>when do I get the value of the cookie,
>
$_COOKIE["cookieName"] will get you the array contining the cookie data
(if it exists)

>and how do I
>populate the username and password fields with the cookie info when the
>checkbox is "checked"???
>
probably best *not* to store the uname / pwd combo in a cookie unless
you have encrypted the string sufficiently for it to not be easily readable

>Are all these things tied to the "Login" or Submit
>button. All questions I need help with!!!
>
>I am using PHP for my login script and mySQL for the database.
>
OK, it seems like you need help with the logic behind this:
(1) at the beginning of your log in script, check for the cookie
existance, decrypt it and use the values to log the individual in
automatically (users can use their browsers to remember uname / pwd
combo's so it is not much use to emulate this IMHO)
(2) If the cookie doesn't exist, display your log in form
(3) on the login process part of your script - check for the value of
the checkbox, if it is set to "checked", use the setcookie function to
write a cookie to the users browser
does that help?

--
Paul Bennett
Internet Developer
Teltest Electronic Design
--------------------------
Phone : 64 4 237 0767
Web : http://www.teltest.com
Wap : http://wap.teltest.com
Email : paul at teltest.com
--------------------------






More information about the thelist mailing list