title: Check if user is already logged in asp.net website
body: <p>I am developing a website where in user is required to login to the system to be able to use it. The current functionality is:
  When user enters username and password, a check is made in DB to check if that user exists and if he has entered a correct password.
  Only then allow that user to login.</p>
  
  <p>It was fine till this point, now client wants to add one more functionality to the logging feature, ie client would like to restrict only 1 session for that user to exists.</p>
  
  <blockquote>
    <p>ie. if user1 is logged in from one browser of the PC then he should
    not be allowed to login from another system or another browser of the same
    PC.</p>
  </blockquote>
  
  <p>How do I do that? I was planning to do it using a bit field in my database which will be set when user logs in 1st time. And if he tries to logging 2nd time check that field and allow to login only if bit field is not set.</p>
  
  <p>But I feel it will cause issues, </p>
  
  <p>1) if user by mistake closes the tab of the browser and tries to log in again he will not able to do so as the bit field will still be set in DB</p>
  
  <p>2) when will the set field will have be cleared if users closes the browser by mistake?</p>
  
  <p>If there is any other way to implement it then you are free to point me in  a correct direction.</p>
  
  <p>As pointed by some of the fellow members there are duplicates to this question but those questions are not really what I am looking for, as <code>they are using form based authentication and I am not</code>.</p>