Commit ae8f08ee authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

HTTP-COOKIES: use the FAQ document layout

parent 33ee6711
Loading
Loading
Loading
Loading
+54 −43
Original line number Diff line number Diff line
Updated: July 3, 2012 (http://curl.haxx.se/docs/http-cookies.html)
                                  _   _ ____  _
                              ___| | | |  _ \| |
                             / __| | | | |_) | |
                            | (__| |_| |  _ <| |___
                             \___|\___/|_| \_\_____|


HTTP Cookies

Overview
========
 1. Cookie overview
 2. Cookies saved to disk
 3. Cookies with curl the command line tool
 4. Cookies with libcurl
 5. Cookies with javascript

==============================================================================

1. Cookie overview

  HTTP cookies are pieces of 'name=contents' snippets that a server tells the
  client to hold and then the client sends back those the server on subsequent
  requests to the same domains/paths for which the cookies were set.

  Cookies are either "session cookies" which typically are forgotten when the
session is over which is often translated to equal when browser quits, or the
cookies aren't session cookies they have expiration dates after which the
client will throw them away.
  session is over which is often translated to equal when browser quits, or
  the cookies aren't session cookies they have expiration dates after which
  the client will throw them away.

  Cookies are set to the client with the Set-Cookie: header and are sent to
  servers with the Cookie: header.
@@ -21,20 +36,18 @@ original Netscape spec from 1994: http://curl.haxx.se/rfc/cookie_spec.html
  In 2011, RFC6265 (http://www.ietf.org/rfc/rfc6265.txt) was finally published
  and details how cookies work within HTTP.

cookies saved to disk
=====================
2. Cookies saved to disk

  Netscape once created a file format for storing cookies on disk so that they
would survive browser restarts. curl adopted that file format to allow sharing
the cookies with browsers, only to see browsers move away from that
  would survive browser restarts. curl adopted that file format to allow
  sharing the cookies with browsers, only to see browsers move away from that
  format. Modern browsers no longer use it, while curl still does.

The cookie file format stores one cookie per physical line in the file with a
bunch of associated meta data, each field separated with TAB. That file is
  The cookie file format stores one cookie per physical line in the file with
  a bunch of associated meta data, each field separated with TAB. That file is
  called the cookiejar in curl terminology.

cookies with curl the command line tool
=======================================
3. Cookies with curl the command line tool

  curl has a full cookie "engine" built in. If you just activate it, you can
  have curl receive and send cookies exactly as mandated in the specs.
@@ -57,8 +70,7 @@ Command line options:
    tell curl to start the cookie engine and write cookies to the given file
    after the request(s)

cookies with libcurl
====================
4. Cookies with libcurl

  libcurl options:

@@ -89,12 +101,11 @@ libcurl options:
    Extract cookie information from the internal cookie storage as a linked
    list.

cookies with javascript
=======================
5. Cookies with javascript

  These days a lot of the web is built up by javascript. The webbrowser loads
complete programs that render the page you see. These javascript programs can
also set and access cookies.
  complete programs that render the page you see. These javascript programs
  can also set and access cookies.

  Since curl and libcurl are plain HTTP clients without any knowledge of or
  capability to handle javascript, such cookies will not be detected or used.