I have some small applications that I want to secure. I've been using the following setup that I think is fairly safe, but I've never been able to set my mind at ease that it really is. Could you (yes, you!) give me some reviews on the security of this? It doesn't need super-security like credit card data, but I suppose secure is secure. And I apologize in advance if this is too much code. This is my first time here.
Summary
Cookie-based Sessions. User table is:Cookie-based Sessions. User table is:
- usernameUsername field (cleartext)
- randomRandom/unique salt field (created with
mt_rand()
at signup - passwordPassword field (sha256SHA256 hash).
- (among other stuff)
Login method takes username, looks for the dbDB row, gets the salt, adds it to the end of the posted password, calcs a sha256SHA256 hash for that string, and compares that to the password field in the dbDB.
Code
**auth.php include at beginning of app**auth.php include at beginning of app
andAnd the relevant part of the user class: