1

I'm building an extra provider for Sickbeard and having problems with my cookies. I've been looking for a long time now after why cookies are missing in the HTTP Response when using requests.

login_params = {'uid': sickbeard.PROVIDER_USERNAME,
                'pwd': sickbeard.PROVIDER_PASSWORD,
               }

try:
    response = self.session.post(self.urls['login'], data=login_params, timeout=30)
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError), e:
    logger.log(u'Unable to connect to ' + self.name + ' provider: ' +ex(e), logger.ERROR)
    return False


The response only contains one cookie the __cdfuid cookie:

requests.utils.dict_from_cookiejar(self.session.cookies)['__cfduid']


The cookies that I get (and want) when logging into the provider are __cdfuid | uid | pass:

requests.utils.dict_from_cookiejar(self.session.cookies)['__cfduid']
requests.utils.dict_from_cookiejar(self.session.cookies)['uid'] #Not passed
requests.utils.dict_from_cookiejar(self.session.cookies)['pass'] #Not passed


I don't know if it matters but the __cdfuid cookie is the only one that has HttpOnly and path=/ parameters set. The other two just has expiration and the actual data.

17
  • what is response.cookies? Commented Apr 13, 2014 at 0:39
  • Only one param, __cfduid not the other two. Commented Apr 13, 2014 at 0:44
  • how do you know that uid and pass cookies are set? Commented Apr 13, 2014 at 0:47
  • When I look into the response.text I see that I successfully logged in, so I presume the cookies to be set. When I try the same post request in Chrome I get the header with the uid and pass cookies set. Commented Apr 13, 2014 at 0:51
  • successful login doesn't mean that uid and pass must be set. What happens if you clear cookies in Chrome before the request? Commented Apr 13, 2014 at 0:55

1 Answer 1

3

response.cookies contains only the cookies set by that response. If you are redirected you may find some cookies were set by the redirect. These will not be present on response.cookies, though they will be present on response.history[i].cookies.

You should always examine the cookies dictionary on the Session, not the responses, if you want to get a full idea of what cookies have been set.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, but how is it that the I posted above uses self.session to get the cookies and it only returns the __cfduid cookie?
Check all of the history responses and confirm that the cookies were in fact set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.