Trying to understand the sessions.

  1. 7 months ago

    I would like to allow only one access per user in my webapp; but the code i wrote i'snt working; every time return 'user alredy conected'; but he is not.

            For i As Integer = 0 To App.SessionCount - 1
              If App.SessionAtIndex(i).Identifier <> Session.Identifier Then
                If Session.MyUserName=App.SessionAtIndex(i).MyUserName Then
                  MsgBox "User Alredy Connected."
              End If

    Could you help me?

  2. Where did you put this code?

  3. Inside Action of a button in my login form.

  4. The problem probably has to do with the fact that sessions persist for a little time after the user navigates away from the app. If you truly want only one login per user, you might instead try closing the previous session instead of disallowing the new one. In your loop, instead of the msgbox and showurl, just put app.sessionatindex(I).close.

or Sign Up to reply!