blob: 2b736539e4ceca6863eed4776fcf90bbd70c2d88 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001c: Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
2SPDX-License-Identifier: curl
3Short: b
4Long: cookie
5Arg: <data|filename>
6Protocols: HTTP
7Help: Send cookies from string/file
8Category: http
9Example: -b cookiefile $URL
10Example: -b cookiefile -c cookiefile $URL
11See-also: cookie-jar junk-session-cookies
12Added: 4.9
13Multi: append
14---
15Pass the data to the HTTP server in the Cookie header. It is supposedly the
16data previously received from the server in a "Set-Cookie:" line. The data
17should be in the format "NAME1=VALUE1; NAME2=VALUE2". This makes curl use the
18cookie header with this content explicitly in all outgoing request(s). If
19multiple requests are done due to authentication, followed redirects or
20similar, they will all get this cookie passed on.
21
22If no '=' symbol is used in the argument, it is instead treated as a filename
23to read previously stored cookie from. This option also activates the cookie
24engine which will make curl record incoming cookies, which may be handy if
25you are using this in combination with the --location option or do multiple URL
26transfers on the same invoke. If the file name is exactly a minus ("-"), curl
27will instead read the contents from stdin.
28
29The file format of the file to read cookies from should be plain HTTP headers
30(Set-Cookie style) or the Netscape/Mozilla cookie file format.
31
32The file specified with --cookie is only used as input. No cookies will be
33written to the file. To store cookies, use the --cookie-jar option.
34
35If you use the Set-Cookie file format and do not specify a domain then the
36cookie is not sent since the domain will never match. To address this, set a
37domain in Set-Cookie line (doing that will include sub-domains) or preferably:
38use the Netscape format.
39
40Users often want to both read cookies from a file and write updated cookies
41back to a file, so using both --cookie and --cookie-jar in the same command
42line is common.