how to Prevent Multiple Concurrent User Logins For The Same UserName RRS feed

  • Question

  • User-1051135784 posted

    how to  Prevent Multiple Concurrent User Logins For The Same UserName

    Tuesday, February 21, 2012 3:42 AM

All replies

  • User197322208 posted

    add a field named : already logged in

    On session_Start put a value (1)

    on session_end clear the value(0)

    if it is 1 do not permit logging again

    Tuesday, February 21, 2012 3:49 AM
  • User-1051135784 posted

    Thanks ignatandrei for reply.i required  actully only one login allowed at same time. if  a user login with the same credential  it allow to logged in the user but if another user  is already logged in with the credential it automatically loged out  at the same time. please advice its very urgent.

    Tuesday, February 21, 2012 4:07 AM
  • User33233192 posted
    1. Add a List<string> object to Application variable.
    2. When a user logs in then store the username in this Application variable only if the UserName not there in this List<string> object
    3. If exists, then dont allow logging in, say somebody logged-in.

    Sample code will be as follows -

    in the Login Page -> Before validating the user check

    List<string> userList = null;
    if(Application["Users"] == null)
      userList = new List<string>();
      userList = Application["Users"] as List<string>();
    //Do this after User is validated
      return "User already logged-in";
     Application["Users"] =  userList;

    Tuesday, February 21, 2012 5:41 AM
  • User-1051135784 posted

    thanks for the reply ,but when a user try to login with same login id and password then it allowed to be login and othe user who have already login is sign out autometically.

    Tuesday, February 21, 2012 6:19 AM
  • User1052573622 posted

    Store the session object in List along with User Id/Name and if you find that user already logged in you can invalidate the previous session and insert/update new session object.


    Monday, April 9, 2012 5:35 PM
  • User-707554951 posted

    Hi bhupender,

    You Can do it by many ways, simple approach is

    1.Set one flag at the time of login into database.

    2.Check flag every time when you are sign in.

    3. Remove flag at time of logout.

    You also could use the way in the following link:




    Best regards


    Tuesday, February 21, 2017 6:00 AM