title: Codeigniter - How to avoid multiple login of an user storing his session in database
body: <p>I'm developing a web app with Codeigniter. </p>
  
  <p>This app has a login page: i want to avoid that 2 people enter with the same credentials in the same moment. To do this i thought to store the value gotten from the function session_id() in my database. In this way, i can check in every page if the user has the same session_id stored in the db, if not he is logged out. This solution seems to work (i've tried using two browser) but seems like the value returned by session_id() changes over time. </p>
  
  <p>What am i wronging? session_id() (explained <a href="https://www.codeigniter.com/user_guide/libraries/sessions.html#accessing-session-metadata" rel="nofollow noreferrer">here</a>) doesn't keep the same value for the whole session? </p>
  
  <p>Does exist a better way to realize that?</p>
  
  <p>Thank you in advance and sorry my english not perfect</p>