Add a Cookie to a Curl

How to add a cookie to a curl request.

First, find your cookie. Perhaps you're making a test request to an API that your web app uses. You could fire up the web app, authenticate, open devtools and see the cookie in the request headers. Copy it. Keep it secret. Keep it safe.

Then back to the terminal where you belong:

curl --cookie "=" 

The notable option is here is --cookie. The format of the cookie header is for to send the cookie name, followed by an = equal sign, followed by the cookie value.

For example:

curl --cookie "myjwt=abc123" http://localhost:8080/my/api