title: session invalidate in JSF2.0
body: <p>I'm using <strong>JSF2.0 with jsp</strong>.I'm trying to incorporate session invalidation in my project.I've tried using the following code.</p>
  
  <pre><code>&lt;h:commandButton value="Logout" action="#{bean.logout}" &lt;/h:commandButton&gt;
  </code></pre>
  
  <p>and my bean class contains the following method</p>
  
  <pre><code>   public class Bean{
      public String logout(){
        FacesContext context = FacesContext.getCurrentInstance();
        HttpSession session = (HttpSession)context.getExternalContext().getSession(false);
        session.invalidate();
        return "login";
      }
     }
  </code></pre>
  
  <p>where string login redirects to login page.</p>
  
  <p>my project has several pages which includes a header page..when i tried the above way...<strong>it was working fine when i click on logout from the very first page...If i try the same after going to other pages, its not logging out</strong>.Can anyone help me on this...is this the way we invalidate a session here???</p>
  
  <p>UPDATE</p>
  
  <p>I also tried using "*" in the navigation rule so that each page can be redirected to Login...but still the issue was same</p>