Get Logged in Count
-
Hi guys, I am new to ASP.net and I am trying to achieve the following: I have created a login page where I want only 1 user logged in at any period. Is there a way to get the current # of user logged in, in ASP.Net? Basically, when second user tries to login, I want to check if there is another user logged in. I tried using session but that doesn't work because each user is on a different computer browsing the site. Please help!!!!
Sameer
-
Hi guys, I am new to ASP.net and I am trying to achieve the following: I have created a login page where I want only 1 user logged in at any period. Is there a way to get the current # of user logged in, in ASP.Net? Basically, when second user tries to login, I want to check if there is another user logged in. I tried using session but that doesn't work because each user is on a different computer browsing the site. Please help!!!!
Sameer
Saamir wrote:
I have created a login page where I want only 1 user logged in at any period
what do you meant only 1 use logged in at any time? I hope you not restricting Only ONE user to connect to your application at a time. If that is what you want, you are in the wrong place. Web app are meant to be used by multiple users at a time. If you want to limit to a single login to each user, then you need to track who is logged in. When a user logs in then flag that in your users table. Then when the user logs out, remove the flag. Then you need to handle end of session event and remove the flag for that user. When you notice a user tries to log in multiple times, then you can redirect them to different page (may be user already logged in message)
Yusuf May I help you?
-
Saamir wrote:
I have created a login page where I want only 1 user logged in at any period
what do you meant only 1 use logged in at any time? I hope you not restricting Only ONE user to connect to your application at a time. If that is what you want, you are in the wrong place. Web app are meant to be used by multiple users at a time. If you want to limit to a single login to each user, then you need to track who is logged in. When a user logs in then flag that in your users table. Then when the user logs out, remove the flag. Then you need to handle end of session event and remove the flag for that user. When you notice a user tries to log in multiple times, then you can redirect them to different page (may be user already logged in message)
Yusuf May I help you?
Hi Yusuf, Yes I want to only allow one user at a time on the webpage considering the sensitive information processing the page does. Are you saying I should use Session_Start and Session_end? If so, pardon my ignorance but how do I implement these functions?
Sameer
-
Hi Yusuf, Yes I want to only allow one user at a time on the webpage considering the sensitive information processing the page does. Are you saying I should use Session_Start and Session_end? If so, pardon my ignorance but how do I implement these functions?
Sameer
-
-
Yusuf, I know that is what I need to do but my question is how do I go about doing that. If I am updating the database then how do I know that the user has not just closed the webpage instead of loging out. Do you know what I mean?
Sameer
I don't know your level of asp.net competency, but your question is a bit silly - Session_End signals the session is expiring, has nothing to do with user logging out or browser closing - Browser Closing - There is no way you can detect this from the server. You can write some js to detect browser closing ( mind you there is no browser support for this, all is behind the door hack) - user logout - the user clicked on logout, so you know that, don't you, don't you....
Yusuf May I help you?
-
I don't know your level of asp.net competency, but your question is a bit silly - Session_End signals the session is expiring, has nothing to do with user logging out or browser closing - Browser Closing - There is no way you can detect this from the server. You can write some js to detect browser closing ( mind you there is no browser support for this, all is behind the door hack) - user logout - the user clicked on logout, so you know that, don't you, don't you....
Yusuf May I help you?
-
Yusuf, dude, it is just a question, no need for expertise talk or sarcastic talk. Hats off to your smartness and thank you for your help.
Sameer
no pun intended ;)
Yusuf May I help you?