I'm using Postman to test and play with an API.
For the login url, the API requires sending a POST request with username
and password
as fields. I do this, and I get a 200
response with the message that I am logged in.
I then try another request to get user data. However, I get a response that I am not logged in.
I realized this problem is most likely because the cookie that is sent to me when I log in is not included in the next Postman request.
So my question is, how do I save and include cookies for future requests?
Store the cookie value you want to use in a global variable.In Tests
tab of login request, write
postman.setGlobalVariable('key', postman.getResponseCookie("cookieName").value);
Pass along with the value in the Headers
tab as a cookie in get user request:
Cookie | cookieName={{key}}