title: Confusion regarding session in JSF 2.0
body: <p>I have a confusion regarding session valid. I read that session belongs to browser not to tabs. Means if you open a browser and open your hotmail account, then close the browser, and then again open it, you have to logged in again. But if you open the browser and open your hotmail in new tab and then close the tab and then again open the hotmail in new tab then you are already login. But in maintaining session i am encountering something very confusing. Java has a check for valid session like </p>
  
  <pre><code>/**
   * Each time user closes the browser then this will become null, but then onwards it always
   * has value, which is called cliendId
   */
  String sessionID = httpServletRequest.getRequestedSessionId();
  
  /**
   * Each time user close the tab or browser or session expires automatically this will
   * become false
   */
  boolean sessionValid = httpServletRequest.isRequestedSessionIdValid();
  </code></pre>
  
  <p><strong>getRequestedSessionId()</strong> is fine. When you open your website first time then it is null but then it always has the same value. Indicating that user is using the same browser. Fine. But <strong>isRequestedSessionIdValid()</strong> is very confusing to me. when-ever i close the tab then it become null. Why it is getting null? why my session is not valid if i close the tab? Do i need to set something in my web.xml file to tell java that do not expire session on tab closing?</p>
  
  <p>Thank you.</p>