lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | Short: b |
| 2 | Long: cookie |
| 3 | Arg: <data> |
| 4 | Protocols: HTTP |
| 5 | Help: Send cookies from string/file |
| 6 | --- |
| 7 | Pass the data to the HTTP server in the Cookie header. It is supposedly |
| 8 | the data previously received from the server in a "Set-Cookie:" line. The |
| 9 | data should be in the format "NAME1=VALUE1; NAME2=VALUE2". |
| 10 | |
| 11 | If no '=' symbol is used in the argument, it is instead treated as a filename |
| 12 | to read previously stored cookie from. This option also activates the cookie |
| 13 | engine which will make curl record incoming cookies, which may be handy if |
| 14 | you're using this in combination with the --location option or do multiple URL |
| 15 | transfers on the same invoke. |
| 16 | |
| 17 | The file format of the file to read cookies from should be plain HTTP headers |
| 18 | (Set-Cookie style) or the Netscape/Mozilla cookie file format. |
| 19 | |
| 20 | The file specified with --cookie is only used as input. No cookies will be |
| 21 | written to the file. To store cookies, use the --cookie-jar option. |
| 22 | |
| 23 | Exercise caution if you are using this option and multiple transfers may |
| 24 | occur. If you use the NAME1=VALUE1; format, or in a file use the Set-Cookie |
| 25 | format and don't specify a domain, then the cookie is sent for any domain |
| 26 | (even after redirects are followed) and cannot be modified by a server-set |
| 27 | cookie. If the cookie engine is enabled and a server sets a cookie of the same |
| 28 | name then both will be sent on a future transfer to that server, likely not |
| 29 | what you intended. To address these issues set a domain in Set-Cookie (doing |
| 30 | that will include sub domains) or use the Netscape format. |
| 31 | |
| 32 | If this option is used several times, the last one will be used. |
| 33 | |
| 34 | Users very often want to both read cookies from a file and write updated |
| 35 | cookies back to a file, so using both --cookie and --cookie-jar in the same |
| 36 | command line is common. |