...

View Full Version : Remember Me - Cookie



pperrier
09-25-2003, 09:17 PM
Hi All,

I'm trying to do the usual "Remember Me" checkbox on my login page.

I have found bit and pieces at different places but I'm still stuck. I either have a problem to read the cookie, or detecting if there is one, etc.

Anybody has a sample code doing that?

Thanks in advance,

Pat

Nightfire
09-25-2003, 09:33 PM
<?php

// check if cookie exists
if(isset($_COOKIE['rememberme'])){
// login user
}else{
// show html form
}
?>



<?php

// process login form
// usual form validation etc here
// DON'T PRINT ANYTHING OUT TO THE PAGE BEFORE YOU SET A COOKIE, OR YOU'LL GET ERRORS.

setCookie("rememberme",$username,time()+36000);
// cookie set, get value of cookie by echoing $_COOKIE['rememberme']
?>


http://php.net/setcookie



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum