Session + Client Machine Restart Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sanndeb
    New Member
    • May 2010
    • 33

    Session + Client Machine Restart Issue

    Hi All, Hope You Are Fine :), I Got A situation Here....

    When a user log's with his login id on my web application i set a tag in the DB to "1" so that no other user with the same id can login from any other machine with the same login id, when he logs out i reset the tag to "0".

    But the problem here occurs is that if a user gets logged in & then his machine suddenly restarts the tag in DB remains "1" & hence from the next time he can't be able to re login.

    Is there a way to solve the issue.... or a better way how not to allow two users to login with the same login id at the same time.

    Thanks
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Add a Global.asax file to your application. In that file you will be able to implement a method that handles the Session_End Event. (Only if you are using InProc Session...InPro c is the default configuration for Session).

    -Frinny

    Comment

    • sanndeb
      New Member
      • May 2010
      • 33

      #3
      Does Session_End event catch machine restart or power off?

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        No, it doesn't.
        But the Application_Loa d event is executed when the web application is first loaded after a reboot...you can do your clearing at that point too.

        Comment

        • sanndeb
          New Member
          • May 2010
          • 33

          #5
          But I was talking about restart of a client machine without using the proper logout, then what's the way to log the user out forcefully, i.e change a tag in DB that the user is logged out?

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            If the client's computer reboots, then their Session will time out after 20 minutes (by default) and the Session_Timeout event is fired....So if the user comes back within 20 minutes and their cookies have been cleared, there is a chance that there will be about 20 minutes of waiting before they can log in again....if cookies weren't cleared, then they will still be "logged in".



            -Frinny

            Comment

            • aspdotnetuser
              New Member
              • Nov 2010
              • 22

              #7
              Just keep the user identification in the session variable as a key. check for the key during every login and allow user if key is null else skip saying user already online..when user is already online, key exists and parallel login is prevented. This way even if your client machine exits in a haphazard manner..session is cleared and user is allowed login again.

              Comment

              Working...