php - Keep a user logged in with cookies -
i have forum , want keep users logged in if check check box says logged it. added php code set cookie :
$year = time() + 31536000; if($_post['remember']) { setcookie('email', $_session['email'], $year); } elseif(!$_post['remember']) { if(isset($_cookie['remember_me'])) { $past = time() - 100; setcookie(email, gone, $past); } }
but, how keep them signed in forum using cookie, have been stuck on time now.
put code on top of login page
if(isset($_cookie["email"])){
$_session['email']=$_cookie["email"];
header("location: some-page.php");
exit();
}
thats all
Comments
Post a Comment