I was looking at the source code of SessionMiddleware: class SessionMiddleware(object): def process_request(self, request): engine = import_module(settings.SESSION_ENGINE) session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None) request.session = engine.SessionStore(session_key)
If I understand it correctly, for every request SessionMiddleware.process_request() will get the sessionid from the cookie and then create a new SessionStore instance using that sessionid. And when I looked at the source for __init__() of SessionStore and SessionBase: class SessionStore(SessionBase): def __init__(self, session_key=None): super(SessionStore, self).__init__(session_key) class SessionBase(object): def __init__(self, session_key=None): self._session_key = session_key self.accessed = False self.modified = False So basically SessionStore just creates a new instance without trying to look up in the database to see whether that session already exists or not. But shouldn't that be the whole point of session -- for every request Django needs to look up in the session database to see if the session is already there? I'm guess at someplace this database lookup takes place but I can't find it. Can you tell me where can i find it? Or did I misunderstand how session work in Django? Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.