def login(self, username=None, password=None, remember_me=False): print(remember_me) if username and password: user = authentication.check_password(username, password) if user: user = authentication.login(cherrypy.session, user) if remember_me: username, cookie_id = user.get('username'), uuid.uuid4().hex self.setCookie( "%s|%s" % (username, cookie_id)) cookie_expire_timestamp = datetime.datetime.fromtimestamp(COOKIE_EXPIRE).strftime('%Y-%m-%d %H:%M:%S') UserDao.update_cookie_id(cookie_id, cookie_expire_timestamp, username) self.index(); else: try: self.unsetCookie() except: pass redirect('/login.html?failed=true') else: redirect(URL_LOGIN)