Delete cookies from Postman

I want to delete the cookies from Postman using test cases.
Cookie jar isn’t working. Please help.

1 Like

Hey @ksingh778

Welcome to the community! :rocket:

What’s ‘not working’ for you?

Could you walk us through the process and share some images of what you’re seeing.

If your using some code in the tests tab, could you also share this please.

Without more information it’s going to be difficult to suggest a solution.

More information about cookies can be found here:
https://learning.postman.com/docs/sending-requests/cookies/

https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-with-request-cookies

Getting the following error:

Error: CookieJar store is not synchronous; use async API instead

After hitting a request I got 3 cookies. I have to verify the cookie creation for which I can use pm.cookies.has(“cookiename”).
Then I have to clear these cookies, so that these cookies doesn’t alter the next hit. I want to do this through tests.

To get programmatic access to the cookies - you would first need to whitlist the domain.

https://learning.postman.com/docs/sending-requests/cookies/#whitelisting-domains-for-programmatic-access-of-cookies

After doing this you should be able to use the functions list on that part to clear out the cookies.

Can you share your test code so we can see what you have so far, that’s always better than trying to explain what’s in the Test sandbox :smile:

@danny-dainton - I have the same issue. I whitelisted the domains, restared my Postman and I’m trying to use the below piece of code to delete cookies and its giving me error “Error: CookieJar store is not synchronous; use async API instead.” I’m using Postman v8.5.0 version of Postman. I have this script in my Pre-requisite tab. let cookieJar = pm.cookies.jar();
console.log(cookieJar);

Note:If I remove the console.log line, I don’t see any error.

1 Like