Trying to understand the sessions.

  1. 6 weeks 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."
                  App.SessionAtIndex(i).ShowURL(App.URL)
                End
              End If
            Next

    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!