Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postman - Setting a cookie from a global variable with "Tests" code

Tags:

postman

What i want to do is to take a cookie value I've received after a "GET" message , set it's value as a global variable, then set it as a session cookie for a specific host, and later on use it in other requests.

Currently i'm doing this manually via this menu:

enter image description here

Is that possible?

like image 775
Shizzle Avatar asked Oct 29 '22 09:10

Shizzle


1 Answers

What you need to do is in the Test on response store the value you want to use in a global variable postman.setGlobalVariable('key', value) then in the request you want to use it as a cookie, pass along the value in the header as a cookie where:

Cookie | cookieName={{key}}

Check out the MZN docs on Cookie to see how to send multiple cookies in one header.

like image 117
ThomasReggi Avatar answered Dec 08 '22 00:12

ThomasReggi