I am writing a client side HTML page with jQuery that calls web services for various activities on a server with a database.
I have a login page that ask for the usual username/password and I want to add a “Remember Me” checkbox. I was wondering what are the best way to store those information (username/password)? Is cookies a safe pratice?
Don’t save neither user nor password. It’s your site, you don’t need them to validate a user if you make the appropriate arrangements:
Create a new database table to store remembered log-ins with at least:
When the user checks the Remember Me box, generate a new entry and send back the long random ID.
When you receive a request from an anonymous user, check for the cookie and, if appropriate, log him in.
You can combine with as additional security checks you consider (store dates to remove old logins, IP checks…), but that’s the general idea.