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/profileExplanation
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
HTTP Methods
GET, POST, PUT, and DELETE requests.
Headers
Set and inspect request and response headers.
Authentication
Basic, bearer, and OAuth credentials.
Upload and Download
Transfer files to and from a server.
Proxies
Route requests through HTTP or SOCKS proxies.
Follow Redirects
Chase 3xx responses automatically.