Search code examples
http-headerspostman

How to get all Set-Cookie headers with Postman


My app returns two Set-Cookie headers: JSESSIONID and AWSELB.

When I write test in Postman and use postman.getResponseHeader("Set-Cookie") it only returns AWSELB.

Any idea how can I get JSESSIONID?

EDIT: Accepted Answer solved it in one way, now I have same issue but with sending two headers with same key. I should be able to send multiple 'Set-Cookie' headers, but when I do that it looks like only the last one is being sent, first one is overridden.


Solution

  • It seems that getResponseHeader contains only the last header, so it is not really useful when dealing with cookies.

    I would rather suggest you try

    getResponseCookie

    For example:

    tests["Should contain JSESSIONID cookie"] = postman.getResponseCookie('JSESSIONID').value === 'abcdef';
    

    Hope this helps!