diff --git a/requests/sessions.py b/requests/sessions.py index 979c0034..fe0a84e1 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -90,7 +90,10 @@ class SessionRedirectMixin(object): prepared_request.hooks = req.hooks prepared_request.method = req.method prepared_request.url = req.url - cookiejar = resp.cookies + + cookiejar = cookiejar_from_dict({}) + cookiejar.update(self.cookies) + cookiejar.update(resp.cookies) # ((resp.status_code is codes.see_other)) while (('location' in resp.headers and resp.status_code in REDIRECT_STATI)): diff --git a/test_requests.py b/test_requests.py index 31d9fbf9..64003cfc 100644 --- a/test_requests.py +++ b/test_requests.py @@ -118,6 +118,12 @@ class RequestsTestCase(unittest.TestCase): r = s.get(url) self.assertTrue(s.cookies['foo'] == 'bar') + def test_cookie_sent_on_redirect(self): + s = requests.session() + s.get(httpbin('cookies/set?foo=bar')) + r = s.get(httpbin('redirect/1')) # redirects to httpbin('get') + self.assertTrue("Cookie" in r.json()["headers"]) + def test_user_agent_transfers(self): heads = {