logout user and query server only if user is loggedIn