Interview Question
0of 0 votesI have Created Dynamic Web Application...
there is user table with column "enabled" to check if the user is already logged in
enabled = true --> logged in otherwise not
if i logged in , i cannot loggin at the same time in anothe r browser ..
but if i logged in and close the browser, how can i handle further loggin ??
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 on November 25, 2012 Edit | Flag ReplyRead 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.