def wrapper(self, *args, **kwargs): #Get the session parameters auth_id = self.request.cookies.get('auth_id', '') session_id = self.request.cookies.get('session_id', '') #Check the db for the session session = Session.GetSession(session_id, auth_id) if session is None: session = Session() session.session_id = Session.MakeId() session.auth_token = Session.MakeId() session.put() # Attach the session to the method self.SessionObj = session #Call the handler. result = method(self, *args, **kwargs) self.response.headers.add_header('Set-Cookie', 'auth_id=%s; path=/; HttpOnly' % str(session.auth_token)) self.response.headers.add_header('Set-Cookie', 'session_id=%s; path=/; HttpOnly' % str(session.session_id)) return result