Search code examples
cookiespostman

Get and store the value of a cookie using Postman


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


Solution

  • 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 Request Body (If chaining them together) or in any Request Body or Request Header by referencing the value using the {{my_cookie}} syntax.

    A very similar issue can be found here.