2016-11-14 06:40:12 +08:00
|
|
|
Short: b
|
|
|
|
Long: cookie
|
2019-03-14 17:54:10 +08:00
|
|
|
Arg: <data|filename>
|
2016-11-14 06:40:12 +08:00
|
|
|
Protocols: HTTP
|
2016-11-15 16:08:50 +08:00
|
|
|
Help: Send cookies from string/file
|
2020-07-13 20:15:04 +08:00
|
|
|
Category: http
|
2021-08-31 22:37:14 +08:00
|
|
|
Example: -b cookiefile $URL
|
|
|
|
Example: -b cookiefile -c cookiefile $URL
|
2016-11-14 06:40:12 +08:00
|
|
|
---
|
|
|
|
Pass the data to the HTTP server in the Cookie header. It is supposedly
|
|
|
|
the data previously received from the server in a "Set-Cookie:" line. The
|
|
|
|
data should be in the format "NAME1=VALUE1; NAME2=VALUE2".
|
|
|
|
|
|
|
|
If no '=' symbol is used in the argument, it is instead treated as a filename
|
|
|
|
to read previously stored cookie from. This option also activates the cookie
|
|
|
|
engine which will make curl record incoming cookies, which may be handy if
|
|
|
|
you're using this in combination with the --location option or do multiple URL
|
2018-03-21 06:25:12 +08:00
|
|
|
transfers on the same invoke. If the file name is exactly a minus ("-"), curl
|
2020-04-24 22:23:22 +08:00
|
|
|
will instead read the contents from stdin.
|
2016-11-14 06:40:12 +08:00
|
|
|
|
|
|
|
The file format of the file to read cookies from should be plain HTTP headers
|
|
|
|
(Set-Cookie style) or the Netscape/Mozilla cookie file format.
|
|
|
|
|
|
|
|
The file specified with --cookie is only used as input. No cookies will be
|
|
|
|
written to the file. To store cookies, use the --cookie-jar option.
|
|
|
|
|
2021-05-17 05:38:35 +08:00
|
|
|
If you use the Set-Cookie file format and don't specify a domain then the
|
|
|
|
cookie is not sent since the domain will never match. To address this, set a
|
|
|
|
domain in Set-Cookie line (doing that will include sub-domains) or preferably:
|
|
|
|
use the Netscape format.
|
2016-11-14 06:40:12 +08:00
|
|
|
|
2021-02-26 01:12:28 +08:00
|
|
|
This option can be used multiple times.
|
2016-11-14 06:40:12 +08:00
|
|
|
|
|
|
|
Users very often want to both read cookies from a file and write updated
|
|
|
|
cookies back to a file, so using both --cookie and --cookie-jar in the same
|
|
|
|
command line is common.
|