Putting a `Cookie` in a `CookieJar`

Old versions of the Requests library (0.14.2 and older) put new cookies in the jar for you when you pass a CookieJar object:

import requests
import cookielib

URL = '...whatever...'
jar = cookielib.CookieJar()
r = requests.get(URL, cookies=jar)
r = requests.get(URL, cookies=jar)

The first request to the URL fills the jar and the second request sends the cookies back to the server.

This doesn’t work starting with Requests 1.0.0, released in 2012.

Leave a Comment