title: How to add multiple "Set-Cookie" header in servlet response?
body: <p>As per RFC <a href="https://www.rfc-editor.org/rfc/rfc6265#page-7" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc6265#page-7</a> It is allowed to have two headers with same key of &quot;Set-Cookie&quot;. The example provided in RFC is -</p>
  <pre><code>​​Set-Cookie: SID=31d4d96e407aad42; Path=/; Secure; HttpOnly
  Set-Cookie: ​​lang=en-US; Path=/; Domain=example.com
  </code></pre>
  <p>How​ do ​I achieve same with Jetty(or any other servlet container)? When I call  httpServletResponse.addHeader this way-</p>
  <pre><code>​httpServletResponse.addHeader(&quot;Set-Cookie&quot;, &quot;SID=31d4d96e407aad42; Path=/; Secure; HttpOnly&quot;);
  httpServletResponse.addHeader(&quot;Set-Cookie&quot;, &quot;lang=en-US; Path=/; Domain=example.com&quot;);​
  </code></pre>
  <p>I see that the second addHeader() doesn't add a new header. According to javadoc for this method-</p>
  <blockquote>
  <p>Adds a response header with the given name and value. This method
  allows response headers to have multiple values.</p>
  </blockquote>
  <p>So it seems that multiple values of allowed but I am not sure how to go about having multiple &quot;Set-Cookie&quot; in servlet response.</p>