title: How to validate user session on every page
body: <p>I'm working on this project in Codeigniter and i created login and register script but I don't know how to validate user on every page.
  When user logs in what data to store in session (Ci session user_data), so i can compare it to database on every page to se if the session is valid?
  I'm using codeigniter's session class and I'm storing the values automatically in the database. Please help me I'm stuck here...</p>
  
  <p>My session is handled like this :
  <br/>1. When ever any user reaches my webpage he gets unique hashed (md5) session id that is checked when ever a page is loaded. If it exists do nothing if it doesn't generate a new one. It changes every 5 minutes.<br/>
  2. When user logs in what data to pass to so i can compare it to the database later on ( on every page load)</p>
  
  <p>I don't know if storing only the 'is_logged' = 1 cookie is safe. I want to check cookies on every server request.</p>