3

I'm writing a Postman collection to be executed in Postman Runner, which requires that cookies from a first request be used in subsequent requests.

In curl, you can achieve this like so

curl -d "username=x&password=y" -c logincookie.txt https://service.com/login
curl -b logincookie.txt https://service.com/x/profile

I can't seem to do this in Postman.

As documented, in my test for the first request I save the cookie as an environment variable

var login_cookie = postman.getResponseCookie("LOGIN");
postman.setEnvironmentVariable("login_cookie", login_cookie);

and then, as described in this blog post, I add the following header to the subsequent request,

Cookie: {{login_cookie}}

but the server responds to this request as if the cookie was not provided.

How can I pass the cookie from the first response to the second request?

I'm using the Postman for Mac 4.10.7 and have enabled the interceptor with its default settings, although I don't know how to validate that this actually works!

Tadhg
  • 561
  • 5
  • 15
  • I am very interested in achieving the same thing. Seems there is no way to do this. – ThomasReggi Sep 14 '17 at 18:43
  • 1
    It's been a year since this question was asked, so maybe this wasn't the case then, but today cookies are persisted across requests in the collection. You can view/confirm this by clicking on the "Cookies" label located just under the Send and Save buttons on the right. – PeterToTheThird Aug 10 '18 at 15:16

0 Answers0