Capturing values of 2 header that have the same key name

I have a login call that creates 2 new session tokens both called SET-COOKIE. I want to ensure that all calls have both of these cookies referenced (sometimes older versions will be persistent and cannot be cleared programmatically as they are httponly).
How can I get each value into an environment variable when they both are called SET-COOKIE?

How do you differentiate between the two values?

Is it obvious and can you create logic that can programmatically do the same?

Does it matter what the environment variable is called, can you call it cookie1 and cookie2 and does it matter which value is stored in which variable?

The two cookies do have unique names within the value.

For example one SET-COOKIE is named GKSSOTICKET and the other is JSESSION withing the value.

I can call the variable anything I want - I just want to be able to load each of the two SET-COOKIE headers into environment variables so I can reference them in the headers of subsequent calls

What I am trying to solve for is how to parse the header data to capture both when they are called SET-COOKIE in the source

You would have to query the response header for the key name and the unique name in the value.

You can do this in two ways, by separate queries with the key name and the unique name in the value, or a single query to bring back the all of the SET-COOKIE headers, which should return an array, which you can then query for each unique name.

Can you provide an example of how that query would look if I were to go with option 1 and do separate queries?

Can you console log the response headers so I can see what it returns.

It should be something like…

console.log(pm.response.headers);
let GKSSOTICKET = pm.response.headers.find(obj => obj.key === 'Set-Cookie' && obj.value.includes("GKSSOTICKET")).value;
console.log(GKSSOTICKET);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.