title: Python post requests and read cookies in the response
body: <p>I am writing a python program which will send a post request with a password, if the password is correct, the server will return a special cookie "BDCLND".</p>
  
  <p>I did this in Postman first. You can see the url, headers, the password I used and the response cookies in the snapshots below.</p>
  
  <p><a href="https://i.stack.imgur.com/lBP7K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lBP7K.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/U3bbW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U3bbW.png" alt="enter image description here"></a></p>
  
  <p>The response cookie didn't have the "BDCLND" cookie because the password 'ssss' was wrong. However, the server did send a 'BAIDUID' cookie back, now, if I sent another post request with the 'BAIDUID' cookie and the correct password 'v0vb', the "BDCLND" cookie would show up in the response. Like this:
  <a href="https://i.stack.imgur.com/FcFTl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FcFTl.png" alt="enter image description here"></a></p>
  
  <p>Then I wrote the python program like this:</p>
  
  <pre><code>import requests
  import string
  import re
  import sys
  
  def main():
      url = "https://pan.baidu.com/share/verify?surl=pK753kf&amp;t=1508812575130&amp;bdstoken=null&amp;channel=chunlei&amp;clienttype=0&amp;web=1&amp;app_id=250528&amp;logid=MTUwODgxMjU3NTEzMTAuMzM2MTI4Njk5ODczMDUxNw=="
      headers = {
          "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8",
          "Referer":"https://pan.baidu.com/share/init?surl=pK753kf"    
      }
      password={'pwd': 'v0vb'}
      response = requests.post(url=url, data=password, headers=headers)
      cookieJar = response.cookies
      for cookie in cookieJar:
          print(cookie.name)
  
      response = requests.post(url=url, data=password, headers=headers, cookies=cookieJar)
      cookieJar = response.cookies
      for cookie in cookieJar:
          print(cookie.name)
  main()
  </code></pre>
  
  <p>When I run this, the first forloop did print up "BAIDUID", so that part is good, However, the second forloop printed nothing, it turned out the second cookiejar was just empty. I am not sure what I did wrong here. Please help.</p>