title: Session management with Tomcat and cookies
body: <p>I am having a difficult time conceptualizing how Tomcat handles cookies and session management behind the scenes.</p>
  
  <p>When or where does Tomcat issue cookies to manage an <code>HttpSession</code>?  According to <a href="https://stackoverflow.com/questions/595872/under-what-conditions-is-a-jsessionid-created">This question / answer</a>, sessions are created from an initial call to <code>getSession()</code>.</p>
  
  <p>If I am running a <code>Filter</code> and call <code>getSession()</code>, does that automatically attach the necessary cookie (assuming I have configured web.xml to use cookies) to the <code>ServletResponse</code>?  If not, how do I do so?  I am not running any jsp's.</p>