title: JSF PrimeFaces lose data and session
body: <p>I am developing an application with JSF and PrimeFaces. 
  I have a managed been, session scoped, that has username, password and isUserLoggedIn.
  When I process a login component it works and changes my page accordingly. As soon as I move to another page I lose the data the username data. I need to access username during the entire application. 
  Does anyone know why I lose the data which should eb session scoped? why do I keep it from one page and not for the others?
  Thanks</p>
  
  <pre><code>import authentication.AuthenticatorManagerLocal;
  import javax.ejb.EJB;
  import javax.enterprise.context.SessionScoped;
  import javax.faces.bean.ApplicationScoped;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.RequestScoped;
  
  @ManagedBean
  @SessionScoped
  public class UserMB {
      @EJB
      private AuthenticatorManagerLocal authenticatorManager;
  
      /** Creates a new instance of UserMB */
      public UserMB() {
      }
  
      Boolean isUserLoggedIn;
      String username;
      String password;
      String nickName;
  
      public String getNickName() {
          nickName="vanessa";
          return nickName;
      }
  
      public void setNickName(String nickName) {
          this.nickName = nickName;
      }
  
      public Boolean getIsUserLoggedIn() {
          return isUserLoggedIn;
      }
  
      public void setIsUserLoggedIn(Boolean isUserLoggedIn) {
          this.isUserLoggedIn = isUserLoggedIn;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String authenticateUser(){
         isUserLoggedIn= authenticatorManager.authenticateUser(username, password);
         if(isUserLoggedIn)return "Home";
         else
             return null;
      }
  
      public void logout(){
          isUserLoggedIn=false;
          username="";
          password="";
      }
  
      public String goToIndex(){
          return "Index";
      }
  
  }
  </code></pre>
  
  <p>HOME has</p>
  
  <pre><code>&lt;p:commandButton value="SearchCB" action="#{expSearchResultsMB.search()}" ajax="false" /&gt;  
  </code></pre>
  
  <p>inside a custom component  </p>
  
  <p>expSearchResultsMB.search() sends to SearchResults
  where I want to display the username</p>
  
  <pre><code> &lt;h:outputLabel value="#{userMB.username}" /&gt; 
  </code></pre>
  
  <p>I need to access username and isUSerLoggedin in every page of the application.
  When I check if the user is logged in I launch Home if he is.
  Home shows the username correctly, but when from home I use searchCB the landing SearchResults page doesn't show the username.</p>
  
  <p>Can anyone help?</p>