title: Read cookies with curl
body: <p>Curl's "cookie engine" gets enabled when you use --cookie.
  e.g. to let curl understand cookies from a page and follow a location (and thus send back cookies it received): </p>
  
  <blockquote>
    <p><code>curl --cookie nada --location http://www.example.com</code></p>
  </blockquote>
  
  <p>But how do you read cookies received? Tried:</p>
  
  <blockquote>
    <p><code>curl -L -b cookies.txt http://example.com</code><br>
        <code>curl --cookie-jar - https://gmail.com</code></p>
  </blockquote>
  
  <p><code>curl --cookie cookies.txt --cookie-jar newcookies.txt 
  http://www.example.com</code></p>
  
  <blockquote>
    <p>curl --cookie-jar - <a href="https://gmail.com" rel="nofollow noreferrer">https://gmail.com</a></p>
  </blockquote>
  
  <p>Record cookies with curl by using --dump-header (-D) :</p>
  
  <blockquote>
    <p><code>curl --dump-header headers_and_cookies http://www.example.com</code></p>
  </blockquote>
  
  <p>but where is cookies.txt? Cookies are sent as HTTP headers, but I don't see it there. How do we see the outputs?</p>
  
  <p>It was said that --cookie-jar or -c is a better way to store cookies, Curl has cookie parsing engine built-in that comes in use to reconnect to a server and use cookies that were stored from a previous connection but the cookie is not viewable. How can I access the file? 
  It was also stated that it is possible to use previously stored cookies: </p>
  
  <blockquote>
    <p>curl --cookie stored_cookies_in_file <a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a></p>
  </blockquote>
  
  <p><code>-c filename</code> or <code>--cookie-jar file name</code>: Save cookies to file after a completed operation. Curl writes all cookies previously read from a specified file as well as all cookies received from remote server(s). If no cookies are known, no file will be written. To write to stdout, set the file name to a single dash, "-".</p>