title: Keep session after browser restart java
body: <p>I'm working on a small project with java servlets/jstl</p>
  
  <p>I've created a login with a session and I want the browser to keep that session even after a browserrestart.</p>
  
  <p>I've written this code:</p>
  
  <pre><code>HttpSession session=request.getSession();
  session.setMaxInactiveInterval(604800);
  session.setAttribute("loggedOnUser", true);
  </code></pre>
  
  <p>I've set the session timeout to a week. But whenever I close the browser and reopen it I need to login again. When I look at the cookies of my browser, the cookie that contains the sessionId still expires when the browser closes. I thought "setMaxInactiveInterval" would change that to one week. Does anyone know what the problem is?</p>