Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
ws = WebSocket1
If ws.Session.HasAttribute("name") = False Then
'name not found. Go to the login page. This will happen if the user goes to the chat page directly.
WebUtils.RedirectTo(ws, "index.html")
Else
name = ws.Session.GetAttribute("name")
ws.Session.RemoveAttribute("name") 'remove the attribute
'the user will be redirected to the login page next time.
CallSubDelayed3(ChatShared, "NewConnection", Me, name)
txt.RunMethod("select", Null)
End If
End Sub