brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl -c and -b keep a session cookie between two requests

Curl
~/tips/tip-curl-cookie-jar-session

curl -c jar.txt https://example.com/login-page

Saves cookies from one request and sends them with the next one.

Testing a page behind a login needs the cookie from the first request in the second one.

curl -c jar.txt https://example.com/login-page
curl -b jar.txt https://example.com/account

-c writes the cookies the server sets into a file, and -b reads them back and sends them. Using both with the same file in one command also updates the jar. -b with a string that contains =, such as -b 'session=abc', sends it literally and does not treat it as a file name. A session cookie lives only in the jar file, so delete the file afterwards.

Further reading: curl manual

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link