title: Python Requests cookies of a specific request within the session
body: <p>I'm trying to find a way to extract and optionally delete cookies sent by a specific request, instead of checking the session cookie jar.</p>
  
  <p>The Requests library stores cookies of all the requests, and I'm having trouble accessing cookies sent by a request the program is currently working at.</p>
  
  <p>Example code of deleting a session cookie:</p>
  
  <pre><code>import requests
  
  
  s = requests.Session()
  r = s.get('http://httpbin.org/cookies/set', params={'foo': 'bar', 'key2': 'value2'})
  print('Before Clear:')
  print(s.cookies.items())
  &gt;&gt;[('foo', 'bar'), ('key2', 'value2')]
  
  s.cookies.clear(domain='httpbin.org', path='/', name='foo')
  
  print('After Clear:')
  print(s.cookies.items())
  &gt;&gt;[('key2', 'value2')]
  </code></pre>
  
  <p>Now, because this is a session, I can't seem to be able to access the cookies of a specific request, like:</p>
  
  <pre><code>r.cookies['foo']
  </code></pre>
  
  <p>The reason why I need cookies of a specific request is because I'm using <strong>requests-futures</strong>, so when the application is working on a request X, I have other requests working simultaneously, writing to the session cookiejar.</p>
  
  <p>What seems like something I could use is the <a href="http://docs.python-requests.org/en/latest/api/#requests.cookies.RequestsCookieJar.extract_cookies" rel="nofollow">extract_cookies</a> API call.</p>
  
  <p>By the way, how to use the Requests API in requests-futures? For example:</p>
  
  <pre><code>requests.utils.add_dict_to_cookiejar(cj, cookie_dict)
  </code></pre>
  
  <p>Here's the requests-futures short <a href="https://github.com/ross/requests-futures/blob/master/requests_futures/sessions.py" rel="nofollow">source code</a>.</p>
  
  <p>Thank you!</p>