Send cookies with curl
Solution 1:
You can use -b to specify a cookie file to read the cookies from as well.
In many situations using -c and -b to the same file is what you want:
curl -b cookies.txt -c cookies.txt http://example.com
Further
Using only -c will make curl start with no cookies but still parse and understand cookies and if redirects or multiple URLs are used, it will then use the received cookies within the single invoke before it writes them all to the output file in the end.
The -b option feeds a set of initial cookies into curl so that it knows about them at start, and it activates curl's cookie parser so that it'll parse and use incoming cookies as well.
See Also
The cookies chapter in the Everything curl book.
Solution 2:
.example.com TRUE / FALSE 1560211200 MY_VARIABLE MY_VALUE
The cookies file format apparently consists of a line per cookie and each line consists of the following seven tab-delimited fields:
- domain - The domain that created AND that can read the variable.
- flag - A TRUE/FALSE value indicating if all machines within a given domain can access the variable. This value is set automatically by the browser, depending on the value you set for domain.
- path - The path within the domain that the variable is valid for.
- secure - A TRUE/FALSE value indicating if a secure connection with the domain is needed to access the variable.
- expiration - The UNIX time that the variable will expire on. UNIX time is defined as the number of seconds since Jan 1, 1970 00:00:00 GMT.
- name - The name of the variable.
- value - The value of the variable.
From http://www.cookiecentral.com/faq/#3.5
Solution 3:
if you have Firebug installed on Firefox, just open the url. In the network panel, right-click and select Copy as cURL. You can see all curl parameters for this web call.