[Flow] How to read cookies from the response of a Send Request block?

Hi guys,

I am not able to read the cookie set on server-side in Postman Flow. The response includes just one set-cookie header even though there are multiple set-cookie headers. Is this case expected behavior? Is there any workaround for getting response cookies? Or it’s not yet supported?

I am able to read the cookies and log them in the console within Post-Response script:

const cookieList = [
    'cookie-name-01',
    'cookie-name-02',
    'cookie-name-03',
    'cookie-name-04',
]

const cookies = pm.cookies
    .reduce((all, current) => {
        const { name, value, domain, path } = current

        if (cookieList.includes(name)) {
            all[name] = {
                value: decodeURIComponent(value),
                domain,
                path
            }
        }

        return all
    }, {})

Note: Setting environment or global variables in Post-Response test case doesn’t work.

Thanks,
Zuko.

Sorry guys. It seems this question is a duplicate of Getting Set-Cookie in Postman Flow.

1 Like