Using python shell
>>> import requests
>>> cookies = {'sentcookie':'666'}
>>> res = requests.get('http://en.wikipedia.org/wiki/Main_Page', cookies=cookies)
>>> res
<Response [200]>
>>> res.cookies
<<class 'requests.cookies.RequestsCookieJar'>[Cookie(version=0, name='sentcookie',
value='666', port=None, port_specified=False, domain='', domain_specified=False,
domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None,
discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False)]>
>>>
Why is ‘sentcookie’ included in the cookies list returned from the server? I’ve sniffed the communication and no cookie is returned from the server.
Why does requests include it in the list and how can I disable this behavior?
I have the exact same problem and I don’t think I fully understand your answer.
Assuming you want to add cookies to your request according to the documentation
this is the right way to do that:
Now if the server returns cookies you can access them by:
But I don’t expect to get the same cookies that I have sent even if the server didn’t returned them, for some reason it’s happening.
How I can to prevent this behavior?