Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Get Logged in Count

Get Logged in Count

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saamir
    wrote on last edited by
    #1

    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

    Y 1 Reply Last reply
    0
    • S Saamir

      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

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      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?

      S 1 Reply Last reply
      0
      • Y Yusuf

        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?

        S Offline
        S Offline
        Saamir
        wrote on last edited by
        #3

        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

        Y 1 Reply Last reply
        0
        • S Saamir

          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

          Y Offline
          Y Offline
          Yusuf
          wrote on last edited by
          #4

          Saamir wrote:

          Session_end

          Remove the logged on status of the user

          Yusuf May I help you?

          S 1 Reply Last reply
          0
          • Y Yusuf

            Saamir wrote:

            Session_end

            Remove the logged on status of the user

            Yusuf May I help you?

            S Offline
            S Offline
            Saamir
            wrote on last edited by
            #5

            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

            Y 1 Reply Last reply
            0
            • S Saamir

              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

              Y Offline
              Y Offline
              Yusuf
              wrote on last edited by
              #6

              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?

              S 1 Reply Last reply
              0
              • Y Yusuf

                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?

                S Offline
                S Offline
                Saamir
                wrote on last edited by
                #7

                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

                Y 1 Reply Last reply
                0
                • S Saamir

                  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

                  Y Offline
                  Y Offline
                  Yusuf
                  wrote on last edited by
                  #8

                  no pun intended ;)

                  Yusuf May I help you?

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups