title: How to end sessions automatically if user closes the browser
body: <p>I need to end the session automatically when the user is inactive for some particular time say for 10 minutes. We have a method in </p>
  
  <pre><code>HttpSession session=request.getSession();
  session.setAttribute("User", au);
  session.setAttribute("name", firstname);
  response.sendRedirect("doLogin.jsp");
  session.setMaxInterval();
  </code></pre>
  
  <p>but this will end the session even if the user is active for 10 minutes. How can I end the session when the user closes the browser?</p>