Skip to content
curl

Cookies

Send, save, and reuse cookies.

By EZ4Code Team
cookiesession

Code

# Send a cookie
curl -b "session=abc123" https://example.com/

# Save cookies from a response
curl -c cookies.txt https://example.com/login -d "user=alice"

# Reuse saved cookies
curl -b cookies.txt https://example.com/dashboard

# Save and send in one flow (cookie jar)
curl -b cookies.txt -c cookies.txt https://example.com/profile

Explanation

The -b flag sends cookies from a string or file, while -c writes the response's Set-Cookie values to a jar file. Combining -b and -c on the same file maintains a session across multiple requests, mimicking a browser. The jar uses Netscape cookie format, which works across curl invocations and tools.

More curl Snippets