Interview Question
Country: India
but it allows logging in two browsers!! one account can be logged in one time at the same time!
Yes indeed and most common behavior in web context. Check any most popular log-in pages, Facebook, Gmaill, Careecup ... etc. Different browsers will not have a common space to maintain these information. Except storing it at server side with IP. But is is very costly in tems of performance.
I can think of having a refresh timeout(when the live session will fetch latest data) and a session timeout(user being idle for some time). Using that even when the user close the browser, if the last refresh time - login time is greater than any defined idle time say 2 minutes than the value of 'ENABLED' should get updated back to false. A DB trigger can handle that request.
Please share in case you got any other way to handle your request.
Set browser cookie, when user successfully logged in.
- satyacbit November 25, 2012Read the cookie, while opening the application. If there is no cookie, ask for log in. Other wise, he is already logged in and hence enabled = true.
Set the cookie expire as browser close. Hence, when a browser is closed, browser will automatically delete the cookie. Hence, user is no more logged in.