Using the Interceptor to read and write cookies


With the new version of Postman (1.0.2), and the Postman Interceptor (0.2.7), it is now possible to read and write cookies!

With the interceptor on, you can retrieve cookies set on a particular domain (Jetpacks only), and include cookies while sending requests.

Retrieving cookies:

1. Make sure the interceptor is enabled in Postman – Check that the traffic light icon in the top-right corner is green.

Interceptor icon
Interceptor icon

2. In the tests section (Jetpacks must be enabled for this), you can use the “responseCookies” object. This will return an array of cookie objects. To retrieve a particular name, use “postman.getResponseCookie(cookieName)”. This will return a single cookie object. Each cookie object will contain the following properties:

domain, hostOnly, httpOnly, name, path, secure, session, storeId, value

Setting Cookies

1. Make sure the interceptor is enabled.

2. Include the “Cookie” header in the headers section

eg. Cookie: name=value; name2=value2

3. Send the request. The cookies you set will be sent by Chrome along with your request.

Set Cookie
Set Cookie


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

9 thoughts on “Using the Interceptor to read and write cookies

  • Avatar

    I really like and appreciate your blog post. Cool.

  • Avatar

    I have a post which has a response of cookies and a json object. I am able to extract the “id” from the response body, but I can’t get cookie values. I purchase Jetpacks and have interceptor enabled. Here is what is in my test editor:

    var data = JSON.parse(responseBody);

    The quick look shows the value of the id correct. In the response I also see 4 cookie values.

    But the value of test = [object,Object],[object,Object],[object,Object],[object,Object]

    Can anyone help?

    • Avatar

      I am also having a similar issue

      • Avatar

        I resolved with the following:

        var myslCheck = postman.getResponseCookie(“slCheck”);

    • Avatar

      Use postman.getResponseCookie(“slCheck”).value

  • Avatar

    In ubuntu, postman not detects interceptor have installed… any tip?

  • Avatar

    Is there a way to set cookie attributes other than the name and value (e.g. path, domain, etc.)?

  • Avatar

    Aw, this was a really nice post. Finding the time and actual effort to make a good article… but
    what can I say… I put things off a lot and don’t seem to get nearly anything done.

  • Avatar

    Abhijit, this is an Informative Article to write Cookies. Surely i will implement it on my site