1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-16 14:35:03 -05:00

HTTP-COOKIES: use the FAQ document layout

This commit is contained in:
Daniel Stenberg 2012-07-03 10:54:46 +02:00
parent 33ee67112f
commit ae8f08ee59

View File

@ -1,16 +1,31 @@
Updated: July 3, 2012 (http://curl.haxx.se/docs/http-cookies.html)
_ _ ____ _
___| | | | _ \| |
/ __| | | | |_) | |
| (__| |_| | _ <| |___
\___|\___/|_| \_\_____|
HTTP Cookies 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 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 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. requests to the same domains/paths for which the cookies were set.
Cookies are either "session cookies" which typically are forgotten when the 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 session is over which is often translated to equal when browser quits, or
cookies aren't session cookies they have expiration dates after which the the cookies aren't session cookies they have expiration dates after which
client will throw them away. the client will throw them away.
Cookies are set to the client with the Set-Cookie: header and are sent to Cookies are set to the client with the Set-Cookie: header and are sent to
servers with the Cookie: header. 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 In 2011, RFC6265 (http://www.ietf.org/rfc/rfc6265.txt) was finally published
and details how cookies work within HTTP. 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 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 would survive browser restarts. curl adopted that file format to allow
the cookies with browsers, only to see browsers move away from that sharing the cookies with browsers, only to see browsers move away from that
format. Modern browsers no longer use it, while curl still does. 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 The cookie file format stores one cookie per physical line in the file with
bunch of associated meta data, each field separated with TAB. That file is a bunch of associated meta data, each field separated with TAB. That file is
called the cookiejar in curl terminology. 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 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. 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 tell curl to start the cookie engine and write cookies to the given file
after the request(s) after the request(s)
cookies with libcurl 4. Cookies with libcurl
====================
libcurl options: libcurl options:
@ -89,12 +101,11 @@ libcurl options:
Extract cookie information from the internal cookie storage as a linked Extract cookie information from the internal cookie storage as a linked
list. list.
cookies with javascript 5. Cookies with javascript
=======================
These days a lot of the web is built up by javascript. The webbrowser loads 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 complete programs that render the page you see. These javascript programs
also set and access cookies. can also set and access cookies.
Since curl and libcurl are plain HTTP clients without any knowledge of or 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. capability to handle javascript, such cookies will not be detected or used.