cookie.md (2462B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Short: b 5 Long: cookie 6 Arg: <data|filename> 7 Protocols: HTTP 8 Help: Send cookies from string/load from file 9 Category: http 10 Added: 4.9 11 Multi: append 12 See-also: 13 - cookie-jar 14 - junk-session-cookies 15 Example: 16 - -b "" $URL 17 - -b cookiefile $URL 18 - -b cookiefile -c cookiefile $URL 19 - -b name=Jane $URL 20 --- 21 22 # `--cookie` 23 24 This option has two slightly separate cookie sending functions. 25 26 Either: pass the exact data to send to the HTTP server in the Cookie header. 27 It is supposedly data previously received from the server in a `Set-Cookie:` 28 line. The data should be in the format `NAME1=VALUE1; NAME2=VALUE2`. When 29 given a set of specific cookies, curl populates its cookie header with this 30 content explicitly in all outgoing request(s). If multiple requests are done 31 due to authentication, followed redirects or similar, they all get this cookie 32 header passed on. 33 34 Or: If no `=` symbol is used in the argument, it is instead treated as a 35 filename to read previously stored cookie from. This option also activates the 36 cookie engine which makes curl record incoming cookies, which may be handy if 37 you are using this in combination with the --location option or do multiple 38 URL transfers on the same invoke. 39 40 If the filename is a single minus ("-"), curl reads the contents from stdin. 41 If the filename is an empty string ("") and is the only cookie input, curl 42 activates the cookie engine without any cookies. 43 44 The file format of the file to read cookies from should be plain HTTP headers 45 (Set-Cookie style) or the Netscape/Mozilla cookie file format. 46 47 The file specified with --cookie is only used as input. No cookies are written 48 to that file. To store cookies, use the --cookie-jar option. 49 50 If you use the Set-Cookie file format and do not specify a domain then the 51 cookie is not sent since the domain never matches. To address this, set a 52 domain in Set-Cookie line (doing that includes subdomains) or preferably: use 53 the Netscape format. 54 55 Users often want to both read cookies from a file and write updated cookies 56 back to a file, so using both --cookie and --cookie-jar in the same command 57 line is common. 58 59 If curl is built with PSL (**Public Suffix List**) support, it detects and 60 discards cookies that are specified for such suffix domains that should not be 61 allowed to have cookies. If curl is *not* built with PSL support, it has no 62 ability to stop super cookies.