How to Ignore or Clear Cookies in Curl

This article explains how to bypass, clear, or ignore previously saved cookies when executing a new curl command. You will learn the specific command-line flags required to discard active cookie sessions, start a fresh request without loading existing cookie files, and overwrite previously stored cookie data.

By default, curl does not store or send cookies unless you explicitly tell it to do so using the -b (cookie input) and -c (cookie output) options. If you want to ensure no previous cookies are sent, or if you want to reset your cookie state, you can use the following methods.

1. Ignore Existing Cookies Using an Empty String

To force curl to activate its internal cookie engine but start with a completely empty slate (ignoring any existing cookies), pass an empty string to the -b or --cookie option.

curl -b "" https://example.com

This tells curl to accept and handle cookies during the redirect steps of this specific request session, but it will not load any pre-existing cookies from your system.

2. Discard Saved Cookies by Pointing to /dev/null

If your environment or script automatically loads cookies from a specific file, you can force curl to ignore that file by redirecting the cookie input to /dev/null (or NUL on Windows).

curl -b /dev/null https://example.com

Because /dev/null is empty, curl starts a clean session with zero loaded cookies.

If you want to ignore previously saved cookies in a file (e.g., cookies.txt) and overwrite that file with brand-new cookies from the new request, combine -b /dev/null with the -c (cookie-jar) option.

curl -b /dev/null -c cookies.txt https://example.com

In this command: * -b /dev/null ensures no previous cookies are read or sent to the server. * -c cookies.txt writes the new cookies returned by the server into cookies.txt, completely replacing any data that was previously in that file.