Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get and store the value of a cookie using Postman [closed]

Tags:

I need to get the value of a cookie, that is only created when I send a request in postman.

I have tried everything but I don't know how to achieve this. I also need to store that value to use in further requests for my project.

cookie name: JSESSIONID value:09840****************00C44

like image 698
Azzok Avatar asked Mar 13 '18 14:03

Azzok


People also ask

How do you get the cookie value in the Postman?

The cookies are mentioned under the Headers and Cookies tab in the Response in Postman. To work with Cookies, we have to click on the Cookies link available under the Params tab. On clicking on it, the MANAGE COOKIES appears. It contains all the available cookies along with the options – Add Cookie and Delete.

Can Postman store cookies?

Postman's cookie manager enables you to view and edit cookies that are associated with different domains. You can manually create cookies for a domain, or you can capture cookies using the Postman proxy or Postman Interceptor. You can then use the cookies stored in the cookie jar when sending requests in Postman.

Where are Postman cookies stored?

Postman stores cookies inside a Cookie Manager and the stored cookies can be accessed when writing scripts in Postman. The access to cookies inside scripts is exposed thanks to a cookie jar, and you can use that cookie jar to work with cookies inside your scripts. Select a request > Cookies.


1 Answers

You could use the pm.environment.set('my_cookie', pm.cookies.get('JSESSIONID')) function in the Tests tab and store it as an environment variable.

This can then be used in the next/any Request Body or Request Header etc by referencing it using the {{my_cookie}} syntax.

A very similar issue can be found here.

like image 174
Danny Dainton Avatar answered Oct 02 '22 14:10

Danny Dainton