Are two database trips reasonable for a login system?

Posted by Randolph Potter on Programmers See other posts from Programmers or by Randolph Potter
Published on 2011-02-10T22:28:39Z Indexed on 2011/02/10 23:33 UTC
Read the original article Hit count: 242

Filed under:
|
|
|

I am designing a login system for a project, and have an issue about it requiring two trips to the database when a user logs in.

  1. User types in username and password
  2. Database is polled and password hash is retrieved for comparative purposes (first trip)
  3. Code tests hash against entered password (and salt), and if verified, resets the session ID
  4. New session ID and username are sent back to the database to write a row to the login table, and generate a login ID for that session.

EDIT: I am using a random salt.

Does this design make sense? Am I missing something? Is my concern about two trips unfounded?

Comments and suggestions are welcome.

© Programmers or respective owner

Related posts about programming

Related posts about design