title: How to implement "Stay Logged In" when user login in to the web application
body: <p>On most websites, when the user is about to provide the username and password to log into the system, there's a checkbox like "Stay logged in". If you check the box, it will keep you logged in across all sessions from the same web browser. How can I implement the same in Java EE?</p>
  
  <p>I'm using FORM based container managed authentication with a JSF login page.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;security-constraint&gt;
      &lt;display-name&gt;Student&lt;/display-name&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;CentralFeed&lt;/web-resource-name&gt;
          &lt;description/&gt;
          &lt;url-pattern&gt;/CentralFeed.jsf&lt;/url-pattern&gt;
      &lt;/web-resource-collection&gt;        
      &lt;auth-constraint&gt;
          &lt;description/&gt;
          &lt;role-name&gt;STUDENT&lt;/role-name&gt;
          &lt;role-name&gt;ADMINISTRATOR&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
  &lt;/security-constraint&gt;
   &lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;realm-name&gt;jdbc-realm-scholar&lt;/realm-name&gt;
      &lt;form-login-config&gt;
          &lt;form-login-page&gt;/index.jsf&lt;/form-login-page&gt;
          &lt;form-error-page&gt;/LoginError.jsf&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
  &lt;/login-config&gt;
  &lt;security-role&gt;
      &lt;description&gt;Admin who has ultimate power over everything&lt;/description&gt;
      &lt;role-name&gt;ADMINISTRATOR&lt;/role-name&gt;
  &lt;/security-role&gt;    
  &lt;security-role&gt;
      &lt;description&gt;Participants of the social networking Bridgeye.com&lt;/description&gt;
      &lt;role-name&gt;STUDENT&lt;/role-name&gt;
  &lt;/security-role&gt;
  </code></pre>