davo Posted October 16, 2014 Posted October 16, 2014 I'm trying to make logging in a bit easier for users. I've tried dropping a cookies with the user's id and hashed password if the user is logged in, and if they're not logged in, pick up the two cookies and use them to log the last user in. <?php session_start(); if($user->isLoggedin()) { $me = $user; $pass = $user->pass; setcookie("id",$me,time() + 500); setcookie("pass",$pass,time() +500); echo "it is $me and $pass"; }else{ if($session->login($_COOKIE["id"],$_COOKIE["pass"])){ echo "you in";} echo $_COOKIE["id"]; } ?> It doesn't seem to be working though. Where have I gone wrong?
adrian Posted October 16, 2014 Posted October 16, 2014 Would this take care of your needs: http://modules.processwire.com/modules/login-persist/
davo Posted October 16, 2014 Author Posted October 16, 2014 yes it would and thanks. but out of interest, why was my login not working?
adrian Posted October 16, 2014 Posted October 16, 2014 Just a quick guess, but if you are storing the user->pass in a cookie, that would be the hashed version, so you couldn't use that to login again!
davo Posted October 17, 2014 Author Posted October 17, 2014 In fact, I compromised on this. I've used the persistent login, but also dropped a cookie with the user ID. If the user is not logged in, the cookie user ID will be used instead for simple site functions, but obviously in inviting the user to log back in for full function.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now