title: How to convert requests.RequestsCookieJar to string
body: <p>I have a <a href="http://docs.python-requests.org/en/master/api/#requests.cookies.RequestsCookieJar" rel="noreferrer"><code>requests.RequestCookieJar</code></a> object which contains multiple cookies from different domain/path. How can I extract a cookies string for a particular domain/path following the rules mentioned in <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Scope_of_cookies" rel="noreferrer">here</a>?</p>
  
  <p>For example</p>
  
  <pre><code>&gt;&gt;&gt; r = requests.get("https://stackoverflow.com")
  &gt;&gt;&gt; print(r.cookies)
  &lt;RequestsCookieJar[&lt;Cookie prov=4df137f9-848e-01c3-f01b-35ec61022540 for .stackoverflow.com/&gt;]&gt;
  
  # the function I expect
  &gt;&gt;&gt; getCookies(r.cookies, "stackoverflow.com")
  "prov=4df137f9-848e-01c3-f01b-35ec61022540"
  
  &gt;&gt;&gt; getCookies(r.cookies, "meta.stackoverflow.com")
  "prov=4df137f9-848e-01c3-f01b-35ec61022540"
  # meta.stackoverflow.com is also satisfied as it is subdomain of .stackoverflow.com
  
  &gt;&gt;&gt; getCookies(r.cookies, "google.com")
  ""
  # r.cookies does not contains any cookie for google.com, so it return empty string
  </code></pre>