Exemple #1
0
    def set(self, request_handler, session):
        request_handler.set_secure_cookie("session_id", session.session_id)
        request_handler.set_secure_cookie("verification", session.hmac_key)

        session_data = ujson.dumps(dict(session.items()))

        rds.setex(session.session_id, self.session_timeout, session_data)
Exemple #2
0
    def _fetch(self, session_id):
        try:
            session_data = raw_data = rds.get(session_id)
            if raw_data is not None:
                rds.setex(session_id, self.session_timeout, raw_data)
                session_data = ujson.loads(raw_data)

            if type(session_data) == type({}):
                return session_data
            else:
                return {}
        except IOError:
            return {}