Forum Moderators: coopster
yup!
As for storing the ip address, well, it's not overkill because there is no such thing as overkill in my book :), however, not everyone is going to have static ip addresses. I guess though, in that case, they just have to login again :)
I've also read that instead of setting a username cookie, a unique user-id should be implemented. Again, i've only read this and don't know the positives and negatives of this approach.
If a "Remember Me" forgets me because my IP address has changed I would consider it to be broken, as an end user. My own IP does seem to change on occassion. That's why I don't opt-in to "Restrict Access to this IP". And, what if your users are behind AOL, or others?
You could provide an extra layer of security, and comfort for those users with a static IP by offering an option for "Restrict Access to this IP".
Why not do a one way crypt on some combination of the user/pass so that the actual u/p isn't exposed should someone root through the cookies.
e.g. $cookie=md5($user.'some_random_secret_stuff'.$pass.$db_row_id);
..then when you check your cookie against your db, just compare against the crypted version of the fields; off top of head query:
SELECT * FROM users WHERE md5(concat(user,'some_random_secret_stuff',pass,id))='$cookie';
Of course, you could still get in by copying the cookie to another box I suppose, but if you can do that, then you probably don't need to break in anyway...
I am going to be strict on User Agent, nuking the cookie if the UA changes at all.
I ended up setting up blowfish encryption anyways, so I'm just going to use that for this cookie and put the username, password, and a primary key to a row in a "remember me" table that contains UA and IP details.
I need to add a "logged in via cookie and needs to re-authenticate to change their password" logic so that a hijacked cookie can't be used to lock out the actual person.