How to use a specific cookie when get multiple "set-cookies" in API response


I am using an API for creating a session and response contains multiple “Set-Cookie”. How can I select a specific cookie, based on the cookie name?

Presently I have the response like this:

headerFields = loginRequest.getHeaderFields()
cookieI = (responseHeaders[‘Set-Cookie’])
cookieI2 = cookieI.toString()

This gives me one long string with all cookies attached. I only want the “session” cookie and ignore all the rest. What do I do to select that specific cookie.

Thank you in advance

Hi @Yaacov_Silverstein,
responseHeaders[‘Set-Cookie’] will return a list of cookie values. You just need to iterate over that list and get your desired header.

Hi @huynguyen i have my cookie under request Headers. Could you please tell me how to retrieve the cookie?

I need the highlighted part