Sessions lose cookies
See original GitHub issueHi,
It seems that there’s a problem with the mocked HTTP requests returned when using a session - the session cookie is returned in the response object, but does not get set in the session.
I am pretty sure it’s down to the extract_cookies_to_jar function in cookielib/cookies.py:
def extract_cookies_to_jar(jar, request, response):
"""Extract the cookies from the response into a CookieJar.
:param jar: cookielib.CookieJar (not necessarily a RequestsCookieJar)
:param request: our own requests.Request object
:param response: urllib3.HTTPResponse object
"""
if not (hasattr(response, '_original_response') and
response._original_response):
return
# the _original_response field is the wrapped httplib.HTTPResponse object,
req = MockRequest(request)
# pull out the HTTPMessage with the headers and put it in the mock:
res = MockResponse(response._original_response.msg)
jar.extract_cookies(res, req)
The _original_response attribute is missing from the mocked HTTPResponse, so no cookies get pulled out into the jar. I’m trying to come up with a solution and if I do I’ll post here, but I should thought I’d let the community at large know. Perhaps I’m doing something silly 😃
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
What are some things that can cause session cookies to fail ...
Their session tokens are still valid, and they haven't logged out. All of a sudden, they apparently don't have the session cookie anymore....
Read more >Session variable and Cookies losing value - MSDN - Microsoft
When users log into my application, i set some values to a cookie (UserID, emailaddress, UserName etc) these are used often throughout the...
Read more >Lost all my cookies (browser sessions) after Brave crash #4492
This just happened to me (lost all cookies after crash). This is terrible loose of time. I'm considering switching to another browser. Version ......
Read more >HTTP session problems - IBM
HTTP sessions are not getting created, or are lost between requests. By default, the session manager uses cookies to store the session ID...
Read more >Session Restore remembers logins from session cookies
Our focus is on end users and consumers, not on shared computer labs, and the value of this feature is pretty huge to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
I want to report that the issue still persists. Following example reproduces it:
Closing as #285 was merged.