You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When redis or memcache clear the key/value data, session_backend.get() will return None. as the request.session will be None. None object cannot call update().
This bug happens when the redis server migrate to the new server with no data, but client brower send the original session key, then exception rasied.
Looking into the code, on init.py line 80-96:
`
connection = HTTPConnection(scope)
initial_session_was_empty = True
if self.cookie_name in connection.cookies:
data = connection.cookies[self.cookie_name].encode("utf-8")
try:
data = self.signer.unsign(data, max_age=self.max_age)
if self.backend_type == BackendType.cookie or not self.session_backend:
scope["session"] = json.loads(b64decode(data))
else:
session_key = json.loads(b64decode(data)).get(
self._cookie_session_id_field
)
scope["session"] = await self.session_backend.get(session_key)
scope["__session_key"] = session_key
######### SHOULD ADD THE CODE HERE
if scope["session“] == None:
scope["session"] = {}
################################
initial_session_was_empty = False
`
The text was updated successfully, but these errors were encountered:
I had the same error when I started using it with redis backend, I thought there was a bug.
But then I realised it is probably because I didn't use the correct way to update and read the session.
It works if you try to set the session by following the document:
When redis or memcache clear the key/value data, session_backend.get() will return None. as the request.session will be None. None object cannot call update().
This bug happens when the redis server migrate to the new server with no data, but client brower send the original session key, then exception rasied.
Looking into the code, on init.py line 80-96:
`
######### SHOULD ADD THE CODE HERE
################################
`
The text was updated successfully, but these errors were encountered: