Trying to understand the sessions.

  1. 5 months ago

    Paulo C

    Nov 1 Brazil

    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. Greg O

    Nov 1 Xojo Inc

    Where did you put this code?

  3. Paulo C

    Nov 1 Brazil

    Inside Action of a button in my login form.

  4. Greg O

    Nov 1 Xojo Inc

    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!