def get(self): user_id_cookie_str = self.request.cookies.get("user_id") username = "" if user_id_cookie_str: user_id = hashutil.check_secure_val(user_id_cookie_str) if user_id: user = User.get_by_id(long(user_id)) if user: username = user.username if username == "": self.redirect(APP_PATH + "/signup") else: self.render_page(username)
def get(self): self.response.headers['Content-Type'] = 'text/plain' visits = 0 visits_cookie_str = self.request.cookies.get('visits') if visits_cookie_str: cookie_val = hashutil.check_secure_val(visits_cookie_str) if cookie_val: visits = int(cookie_val) visits += 1 self.response.headers.add_header('Set-Cookie', 'visits=%s' % hashutil.make_secure_val(str(visits))) if visits > 10: self.write("You are the best ever!") else: self.write("You've been here %s times!" % visits)
def read_secure_cookie(self, name): cookie_str = self.request.cookies.get(name) if cookie_str: val = hashutil.check_secure_val(cookie_str) return val