title: login and sessions using CodeIgniter
body: <p>I'm relatively new to a login system. CodeIgniter can store sessions in a database and that's what I'm doing. It stores the basics: session_id, ip, agent, and last_activity with the option of storing custom data. I've read through some tutorials and from what I understand this is how it should work:</p>
  
  <ol>
  <li><p>Check if a session exists for the user (Is this necessary?)</p></li>
  <li><p>Check the session database for a username (this would be a custom entry in the session db) if it doesn't exist, then show the login form. (and after logging in save the username to the session db)</p></li>
  <li><p>If a username exists in the session db, check last_activity. If it's older than desired (or if the session is expired) then show the login form. If it isn't too old, then log them in.</p></li>
  <li><p>To log out, you would just have to remove the username from the session db. (Or should I use: <code>$this-&gt;session-&gt;sess_destroy()</code>)</p></li>
  </ol>
  
  <p>Does that make sense? Should I also store the user's encrypted password in the session db and check that as well? Is there a better/different way?</p>
  
  <p>Thanks.</p>