Cookie will not set for keep me logged in. PHP -
attempting add "keep me logged in". not sure i'm doing wrong, on initial login when "keep me logged in" checked, run:
$email_and_password = array($email_from_html, $pass_from_html); setcookie("stayloggedzod", $email_and_password, time()+3600*24*30); $email_from_html & $pass_from_html user's email , password being stored array , being stored cookie.
now when go site after leaving, initial page this:
if (isset($_cookie['stayloggedzod'])) { $email_and_password = $_cookie['stayloggedzod']; $stored_email = $email_and_password[0]; $stored_password = $email_and_password[1]; //uses e-mail , pass stored in here log website via mysql db, excluded code because know part works. } else { header("location:login.php"); } it returns no errors, couldn't work made quick test page this:
$cookie_data = $_cookie['stayloggedzod']; $the_email = $cookie_data[0]; $the_pass = $cookie_data[1]; $display_string = "this email".$the_email.". password".$the_pass; echo $display_string; no data shows aside "this email" ect.
this first time making keep logged in, not sure i'm missing, hope thorough explanation. -mike
1) should not store sensitive details password in cookie. cookies stored on client side , editable , visible
2) check man page setcookie http://php.net/setcookie
you see second parameter (the value want store) should string (so if want store arrays think of method store them string serialization or json encoding)
Comments
Post a Comment