How to add a Cookie in Postman?

We've learned two methods for adding Cookies in Postman: manually through Headers and by using the Cookie Manager. These steps are straightforward and ensure that the requests carry the correct Cookie information.

Home > Blog > How to add a Cookie in Postman?

In network requests, to successfully communicate with a server, it is sometimes necessary to include specific identity markers within the request. This is where Cookies come into play. Adding Cookies in Postman is a fundamental operation; through simple steps, we can ensure that our requests carry the necessary authentication information, thereby making communication more reliable. Below, we will detail how to easily add Cookies in Postman, enhancing the accuracy of your requests.

1.Creating a New Interface in Postman

Open the Postman application and select or create a new request interface. At the top of the request tab, you will see a URL input box for entering the API or server address you wish to send the request to. Next to the URL input box, there are a series of tabs such as Params, Authorization, Headers, etc. Select the 'Headers' tab. In the 'Headers' tab, you can input various HTTP request headers.

add Cookie in Postman

2.Adding Cookies in Postman

Method 1: Adding in Headers

To add a Cookie, you need to include a new header named 'Cookie.' Click on the 'Key' column beneath 'Headers' to add a new item, and enter 'Cookie' as the key. In the 'Value' column on the same row, input the Cookie value you wish to add. The format of a Cookie is typically 'key=value,' and if you have multiple Cookies, you can separate them with a semicolon (;). For example: 'sessionId=abc123; userId=12345.' Once the Cookie is added, you can continue configuring other settings for your request and then send the request.

add Cookie in Postman

Method 2: Adding via Cookie Manager

You can also directly add and modify Cookies through the Cookie management feature in Postman. Here's how to add Cookies using the Cookie Manager:

1)On the interface for sending the request, find and click the 'Cookies' button to the right of the URL input box. This will open the Cookie Manager window, where you can see all the Cookies for the current domain.

add Cookie in Postman

2)To add a new Cookie, click the 'Add Cookie' button. In the new window, enter your Cookie information. Fields typically include Cookie name, value, domain, path, expiration time (Expires/Max-Age), Secure flag, HttpOnly flag, etc. Once you've filled in all the information, click 'Save.'

add Cookie in Postman

This completes the addition of the Cookie. Note that when you use this method to add a Cookie, Postman will automatically carry the corresponding Cookies for the domain and path when sending requests.

3.Verifying Cookies

After following the above steps, you can send a simple request to verify whether the Cookie has been successfully added. If the response returns without errors, it indicates that the Cookie was successfully added in Postman.

Summary

We've learned two methods for adding Cookies in Postman: manually through Headers and by using the Cookie Manager. These steps are straightforward and ensure that the requests carry the correct Cookie information.

How to add a Cookie in Postman?
We’ve learned two methods for adding Cookies in Postman: manually through Headers and by using the Cookie Manager. These steps are straightforward and ensure that the requests carry the correct Cookie information.

Reference:

Learn more: