How to clear all Cookies or a specific Cookie in Postman

avatar
Borislav Hadzhiev

Last updated: Apr 5, 2024
3 min

banner

# Table of Contents

  1. How to clear all Cookies or a specific Cookie in Postman
  2. Clearing the Cookies in Postman via the DevTools
  3. Programmatically deleting the cookies in Postman using a pre-request script
  4. Prevent cookies for a request to be stored in the cookie jar

# How to clear all Cookies or a specific Cookie in Postman

To clear the cookies or delete a specific cookie in Postman:

  1. Click on the Cookies button at the bottom bar or on the blue Cookies link below the input field with the URL.

click on cookies button

  1. In the Manage Cookies screen, click on the X icon next to the cookies you want to delete.

clear all cookies or delete specific cookie

If you click on the X icon next to a domain, all cookies for the domain are deleted.

You can also manually clear your cookies or delete specific cookies in your browser which also removes the cookies from Postman.

For example, in Chrome:

  1. Press F12 or right-click and click Inspect to open your developer tools.
  2. Click on the Application tab.

clear cookies in browser

  1. Expand the Cookies menu in the left sidebar under Storage.

  2. Right-click on the specific domain and select clear to clear all cookies for the given domain.

  3. If you only want to delete a specific cookie, right-click on the cookie and select Delete.

delete specific cookie in browser

If the cookies aren't synced in Postman after deleting them in the browser, reissue the HTTP request.

# Clearing the Cookies in Postman via the DevTools

You can also clear the cookies in Postman by using the DevTools:

  1. In the top menu, click on View and hover over Developer.

postman show devtools

  1. Click on Show Devtools (Current View).

  2. In the Developer Tools window, click on the Application tab.

  3. Expand the Cookies menu in the left sidebar.

click application tab and clear cookies

  1. Right-click on the https://dekstop.postman domain and click on Clear.

  2. You can also delete a specific cookie by right-clicking on it in the window on the right and selecting Delete.

# Programmatically deleting the cookies in Postman using a pre-request script

You can also use a pre-request script to programmatically delete the cookies before a request is sent.

  1. Click on the Pre-req. or Pre-request button below the input field with the URL.

click pre request

  1. Paste the following JavaScript code into your pre-request code editor.
pre-request.js
const jar = pm.cookies.jar(); jar.clear(pm.request.url, function (error) { // error - <Error> });

The code clears all cookies for the domain and is run before the request is sent.

If you still aren't able to clear the cookies, try whitelisting the domain.

  1. Click on the blue Cookies button below the input field with the URL.

click on cookies button

  1. On the Manage Cookies screen, type the name of the domain and click on Add Domain.

whitelist domain on manage cookies screen

There is also a pre-request script that allows you to remove a specific cookie before issuing an HTTP request.

pre-request.js
const jar = pm.cookies.jar(); jar.unset(pm.request.url, 'cookie name', function (error) { // error - <Error> });

# Prevent cookies for a request to be stored in the cookie jar

If you need to prevent cookies used in a given request from being stored in the Postman cookie jar:

  1. Click on the Settings button for the specific request.

  2. Click on the Disable cookie jar setting to enable it.

settings disable cookie jar

When the setting is enabled, cookies for the specific request are not stored in the cookie jar and existing cookies in the cookie jar are not added to the request headers.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.