title: How to reset JSESSIONID
body: <p>It is considered a good security practice to reset the session cookie when a user authenticates.</p>
  
  <p>How to do this with Java?</p>
  
  <p>My attempt so far is successful, but I was wondering if there's a better way:</p>
  
  <pre><code>public static HttpSession resetSessionId(HttpSession session, 
        HttpServletRequest request) {
      session.invalidate();
      session = request.getSession(true);
      return session;
  }
  </code></pre>