title: set session cookie attribute "Domain" on java-spring-tomcat
body: <p>How can I set session cookie attribute "Domain" for my spring project on tomcat server?  I am using spring security and HTTPS
  Currently I have following :</p>
  
  <pre><code>Set-Cookie: JSESSIONCookie: JSESSIONID=DEAC4422AB4E28A7062C08724C8BCFAA; Path=/myapp/; Secure; HttpOnly.
  </code></pre>
  
  <p>But I want this</p>
  
  <pre><code>Set-Cookie: JSESSIONCookie: JSESSIONID=DEAC4422AB4E28A7062C08724C8BCFAA; Path=/myapp/; Secure; Domain=.localhost; HttpOnly.
  </code></pre>
  
  <p>I have tried to put domain attribute in web.xml withing cookie-config.
  I have tried using spring session [CookieHttpSessionStrategy], but that doesnot work.</p>
  
  <p>There is something like TomcatContextCustomizer , but that doesnot work [actually I might have made some mistake in configuring it]</p>
  
  <p>Also if running on localhost what domain should I set?</p>
  
  <pre><code>obj.setDomain("localhost");//or
  obj.setDomain(".localhost");//or
  obj.setDomain("127.0.0.1");
  </code></pre>
  
  <p>Which one of above is correct? </p>