how to prevent multiple login for same user in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • visweswaran2830
    New Member
    • Nov 2009
    • 92

    #1

    how to prevent multiple login for same user in asp.net

    Hi,

    I want to prevent multiple user login for same user in asp.net.. How can I achieve. Note: I want to control without database concepts
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    Originally posted by visweswaran2830
    Hi,

    I want to prevent multiple user login for same user in asp.net.. How can I achieve. Note: I want to control without database concepts
    Its a bit impossible to control it without a database...

    If you want to prevent same login from multiple places..
    it can only be done through a flag in the database saying user's logged in..

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      This answer will depend on how you implement the login component of your application.

      Most of the time the login is associated with the browser that the user is working with. This means that a user can login using one browser and a cookie is set (whether it be a Session Identifier cookie, or a cookie that contains authentication ticket). Cookies set for one web browser (say Internet Explorer) are not available in another web browser (say FireFox).

      So, in your server side code it's not enough to simply check the user's Session, or the authentication cookie...

      You're going to have to store something server side that checks if the userID is "logged in".

      You could consider using Cache to store the user's ID when the log in... when the user logs in, add the user's name into Cache...so that you can check to see if the user is already logged in whenever a user attempts to login. You can set Cache entries to time out after a while too...so that if the user forgets to log out they wouldn't be locked out of the system forever.

      You could also set a application variable...or you could even use an XML file if you don't want to use a database.

      There are a lot of ways to implement such a solution.

      -Frinny

      Comment

      • Kiti
        New Member
        • Jun 2011
        • 1

        #4
        Hi Frinny,
        I liked your post. I am beginner in .net and want to implement the same functionality in my application using C#. Can you please send me a sample code for what you mentioned above?

        Thanks a lot in advance.

        Kiti

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          I don't really have any sample code.
          If you do not have a database for your users then you can use the web config.

          Maybe you should start by reading this MSDN article on Forms Authentication Explained.

          -Frinny

          Comment

          Working...