title: JSF logout using session.invalidate does not clear the current username?
body: <p>In my JSF application, I get the name of the currently signed in user like this ...</p>
  
  <pre><code>public String getLoggedInUsername() {
    return FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
  }
  </code></pre>
  
  <p>... and I check if the user is signed in like this ...</p>
  
  <pre><code>public boolean isSignedIn() {
    return (getLoggedInUsername() != null);
  }
  </code></pre>
  
  <p>... and when the user signs out, I do this ...</p>
  
  <pre><code>public String doLogout() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    HttpSession httpSession = (HttpSession)facesContext.getExternalContext().getSession(false);
    httpSession.invalidate();
    return "main";
  }
  </code></pre>
  
  <p>My problem is after doLogout(), the getLoggedInUsername() still returns the name of the user that was logged in.  What am I supposed to do to make sure getRemoteUser() returns null after logout?  </p>
  
  <p>Alternately, is there a better way to get if isSignedIn() than just checking the username?</p>
  
  <p>Thanks!
  Rob</p>