cookies docs
authorKenneth Reitz <me@kennethreitz.com>
Wed, 17 Aug 2011 07:58:55 +0000 (03:58 -0400)
committerKenneth Reitz <me@kennethreitz.com>
Wed, 17 Aug 2011 07:58:55 +0000 (03:58 -0400)
docs/user/quickstart.rst

index 4669e81..61d5c7b 100644 (file)
@@ -104,4 +104,33 @@ So, we can access the headers using any capitalization we want::
 If a header doesn't exist in the Response, its value defaults to ``None``::
 
     >>> r.headers['X-Random']
-    None
\ No newline at end of file
+    None
+
+
+Cookies
+-------
+
+If a response contains some Cookies, you can get quick access to them::
+
+    # cookies test url
+    >>> url = 'http://httpbin.org/cookies/set/requests-is/awesome'
+
+    >>> r = requests.get(url)
+
+    >>> print r.cookies
+    {'requests-is': 'awesome'}
+
+The underlying CookieJar is also available for more advanced handing::
+
+    >>> r.request.cookiejar
+    <cookielib.CookieJar>
+
+To send your own cookies to the server, you can use the ``cookies``
+parameter::
+
+    >>> url = 'http://httpbin.org/cookies'
+    >>> cookies = dict(cookies_are='working')
+
+    >>> r = requests.get(url, cookies=cookies)
+    >>> r.content
+    '{"cookies": {"cookies_are": "working"}}'