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.
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.
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.
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.
Update a Cookie
- Open the Cookies Manager.
- Select the cookie to update.
- Change cookie properties.
- Click on the Save button.
Delete a Cookie
To delete the cookie Cookie_1 for the domain example.com:
- Open the Cookies Manager.
- Click on the domain name example.com.
- Click on the cookie name Cookie_1.
- Click on the Close icon X next to domain.
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.
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:
- Open Postman.
- Click on the Interceptors tab.
- Click on the + Add Interceptor button.
- Select the cookie interceptor type and click the Create button.
- Click the Start button to start the interceptor.
- Make a request to the website or API whose cookies are to be captured.
- Once the request has been made, click on the Stop button to stop the interceptor.
- The captured cookies will be displayed in the Cookies tab.
Using Cookies in Requests
To send cookies with a request, follow these steps:
- Open a request to send.
- Click on the Cookies tab.
- Select cookies to send.
- Click the Send Cookies checkbox.
- Click on send button.
- 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.
Cookies Manager in Postman
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:
- 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.
- Cookie Interceptors: Cookie interceptors allow you to automatically capture and manage cookies from API responses.
- Cookie Jars: Cookie jars allow you to store and reuse cookies in your API requests.
This article focuses on discussing Cookie Manager in Postman.