Open In App

Cookies Manager in Postman

Last Updated : 26 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Postman is a popular tool for API testing and development. It has several features that make it ideal for handling cookies that make making and executing API calls easier, including:

  1. Cookie Manager: Cookies Manager Allows viewing, adding, editing, and deleting cookies for a specific domain using the Cookies Manager. This may be beneficial for storing cookies between requests or for testing authentication-requiring APIs.
  2. Cookie Interceptors: Cookie interceptors allow you to automatically capture and manage cookies from API responses.
  3. Cookie Jars: Cookie jars allow you to store and reuse cookies in your API requests.

This article focuses on discussing Cookie Manager in Postman.

What is Cookies Manager in Postman?

Cookies are small text files that are placed on your computer by websites you visit.

  1. They serve to remember your preferences and track your web browsing activities.
  2. For example, a cookie may be used to save products in a shopping cart or to recall your website login credentials.

The Cookies Manager in Postman is a tool that allows you to view and edit cookies stored in your browser. You can also use the cookie manager to add new cookies to your browser.

Why use Cookies Manager in Postman?

There are multiple reasons to use Postman’s cookies manager:

  1. Test APIs: To test APIs that require cookies for authentication or authorization.
  2. Manage cookies: To manage the cookies sent with your API requests.
  3. Debug problems: To debug problems with API requests failing due to cookies.

How to use Cookies Manager in Postman?

Step 1: Open Postman.

Step 2: Click on the “Cookies” tab in the bottom-right corner of the window.

Step 3: The Cookie Manager will be displayed.

Step 4: To view the cookies for a specific domain, click on the domain name in the list.

Cookie Manager

Create a Cookie

1. To create a cookie, click on the + Add Cookie.

Cookie_1=value; Path=/; Expires=Thu, 17 Oct 2024 05:34:02 GMT;

Explanation:

Cookie_1: The name of the cookie.

value: The value associated with the cookie.

Path=/: Define the URL route for which the cookie is valid. In this case the cookie is valid for the entire domain because it is set to the root path (/).

Expires=Thu, 17 Oct 2024 05:34:02 GMT: Specify the expiration date and time of the cookie. After this date and time, the cookie will expire.

Cookie Manager

2. Adding additional features is up to you depending on what you need. For example, to indicate the domain for which the cookie is valid, you can use the domain property. This is a more detailed example:

Cookie_1=value; Path=/; Domain=example.com; Secure; HttpOnly; Expires=Thu, 17 Oct 2024 05:34:02 GMT;

Domain=example.com: Specify the domain for which the cookie is valid. Replace example.com with your actual domain.

Secure: Instructs the browser to only send a cookie if the request is being sent over HTTPS.

HttpOnly: Prevents client-side scripts from accessing the cookie, adding a layer of security.

Cookie Manager

3. After creating the cookie, you can send it to your API call by checking the Send Cookies option located on the request’s Cookies page.

View Cookie

1. Open the Postman Console.

2. Select Requests to view cookies.

3. Click the Show Raw Log button.

View Cookie

View cookie

Update a Cookie

  1. Open the Cookies Manager.
  2. Select the cookie to update.
  3. Change cookie properties.
  4. Click on the Save button.

Delete a Cookie

To delete the cookie Cookie_1 for the domain example.com:

  1. Open the Cookies Manager.
  2. Click on the domain name example.com.
  3. Click on the cookie name Cookie_1.
  4. Click on the Close icon X next to domain.
Delete a cookie

Delete a cookie.

Capturing Cookies

Postman proxy: A Postman proxy is a server that sits between the browser and the website or API. It intercepts all requests and responses sent between the browser and the website or API.

To capture cookies using the Postman proxy:

1. Open Postman.

2. Click on the Proxy tab via(File > Settings > Proxy).

3. Start proxy session.

Capture Cookies

Proxy Session

4. Make a request to the website or API to capture cookies.

5. Once the request is done, click the Stop button to stop the proxy.

6. Captured cookies will be displayed in the Cookies tab.

Postman Interceptor

To capture cookies using the Postman Interceptor:

  1. Open Postman.
  2. Click on the Interceptors tab.
  3. Click on the + Add Interceptor button.
  4. Select the cookie interceptor type and click the Create button.
  5. Click the Start button to start the interceptor.
  6. Make a request to the website or API whose cookies are to be captured.
  7. Once the request has been made, click on the Stop button to stop the interceptor.
  8. The captured cookies will be displayed in the Cookies tab.

Using Cookies in Requests

To send cookies with a request, follow these steps:

  1. Open a request to send.
  2. Click on the Cookies tab.
  3. Select cookies to send.
  4. Click the Send Cookies checkbox.
  5. Click on send button.
  6. Postman will send the cookies with the request.

How to Disable the Cookie Jar?

Postman also has a cookie jar that stores cookies captured using proxies or interceptors. Under the Cookie Jar section, deselect the Enable Cookie Jar checkbox.

Best Example of Cookies

  1. Login Cookie: A login cookie is a good example of a cookie. A cookie is stored on your machine by a website when you log in, authenticating you as the logged-in user. This cookie allows you to access the website without having to log in every time.
  2. Tracking Cookie: Another example of a cookie is one that is used to track your browsing activity on a website. Websites use cookies to collect information about user behaviour on their sites. Using this information, the functionality and presentation of the website can be improved.
  3. Advertisement Targeting Cookie: Cookies can also be used to target advertisements to users. A cookie may be placed on your machine, for example, if you visit an e-commerce website and view a product. Through this cookie the website will be informed that you are interested in that product. The website may use cookies to show you product advertisements the next time you visit a website that displays advertisements.

Conclusion

Modern websites depend heavily on cookies and managing them using Postman and other tools is important for faster API development and testing.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads