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