title: What should I use for user authentication in PHP?
body: <p>I was thinking of writing my own authentication script but I don't know much about security.</p>
  
  <p>From the articles I've reading, it looks like it usually involves hashing the password with a salt and storing it in the database.  Then when user requests to log in, password is hashed and compared with the database.  If it matches, then the user's data is stored in $_SESSION.</p>
  
  <p>However, I don't know if this is secure or not. I read something about storing session keys in the database but I'm not sure about how that works, or how to implement that.</p>
  
  <p>Can someone explain how to implement secure authentication?</p>
  
  <p>Also, are there any suggestions for PHP authentication libraries I can incorporate that are easy to learn instead of writing my own?</p>