Curl's "cookie engine" gets enabled when you use --cookie. e.g. to let curl understand cookies from a page and follow a location (and thus send back cookies it received):
curl --cookie nada --location http://www.example.com
But how do you read cookies received? Tried:
curl -L -b cookies.txt http://example.com
curl --cookie-jar - https://gmail.com
curl --cookie cookies.txt --cookie-jar newcookies.txt
http://www.example.com
curl --cookie-jar - https://gmail.com
Record cookies with curl by using --dump-header (-D) :
curl --dump-header headers_and_cookies http://www.example.com
but where is cookies.txt? Cookies are sent as HTTP headers, but I don't see it there. How do we see the outputs?
It was said that --cookie-jar or -c is a better way to store cookies, Curl has cookie parsing engine built-in that comes in use to reconnect to a server and use cookies that were stored from a previous connection but the cookie is not viewable. How can I access the file? It was also stated that it is possible to use previously stored cookies:
curl --cookie stored_cookies_in_file http://www.example.com
-c filename
or --cookie-jar file name
: Save cookies to file after a completed operation. Curl writes all cookies previously read from a specified file as well as all cookies received from remote server(s). If no cookies are known, no file will be written. To write to stdout, set the file name to a single dash, "-".
You can use the same file to read and write to:
CF="cookie.txt"
curl -b "$CF" -c "$CF" http://www.example.com/
curl --cookie "$CF" --cookie-jar "$CF" http://www.example.com/