Now i am currently coding a PHP site and i am implementing the login page for my site, but the remember me feature in my script is not working,,, here is the code which i placed in header.php after the body tag,,, <?php if(isset($_COOKIE['username']) && isset($_COOKIE['userid'])) { $_SESSION['USERNAME'] = $_COOKIE['username']; $_SESSION['USERID'] = $_COOKIE['userid']; } ?> PHP: this is the code which i placed in login.php if(isset($_POST['remember'])) { setcookie("username", $_SESSION['USERNAME'], time()+60*60*24*100, "/"); setcookie("userid", $_SESSION['USERID'], time()+60*60*24*100, "/"); } PHP: i selected remember me option while loging in and i logged in,,, after that i closed the browser without loging out,,,,, when i open the page again it is not auto loging,,, please help me with this,,,
are you getting the cookie data ? Please try printing out the cookie data print_r($_COOKIE) and see its there. I think you might be needing to set the cookie path also if your $_COOKIE is not having those keys.
You can't put it after the body tag. You have to check for the cookies before headers are sent. Use headers_sent function to check.
What are you tring to do it's very dangerous. Your way if i know the username and the userid i can login in the user account.
i tried this, but nothing is printed i placed the script about doctype, but still no result i know, i am first checking the cookie function without database,,,