Skip to content

Instantly share code, notes, and snippets.

@emadehsan
Last active August 14, 2019 13:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emadehsan/d22951ddc6f15b279da877a841c7f25c to your computer and use it in GitHub Desktop.
Save emadehsan/d22951ddc6f15b279da877a841c7f25c to your computer and use it in GitHub Desktop.
Automatically set cookie in Postman

In the Tests tab of your request, type this code

let cookie = postman.getResponseHeader("Set-Cookie");
postman.setEnvironmentVariable("cookie", cookie);

This will set an environment vairable. In all the requests that need cookie, add to the Request Header

Key: Cookie Value: {{cookie}} // this is the environment variable set by our test

Ref: https://sqa.stackexchange.com/a/33588/18558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment