Good evening, on some unclear occasion to me, self.set_cookie () does not work, which should write a cookie for the user. Even more interesting is that for the first line in the file - everything works, but not for the subsequent ones. At the same time, I know for sure that the user is in the file and everything comes to self.set_cookie (...), but the method itself does not do what it should.

class LoginHandler(tornado.web.RequestHandler): def post(self): login = self.get_argument("login", "") pswrd = self.get_argument("pswrd", "") if login and pswrd: f = open(DB, "r") lines = f.readlines() f.close() for line in lines: line = line.replace("\n","") line = line.replace("'","\"") line = json.loads(line) if line["login"] == login and line["password"] == pswrd: self.set_cookie("user", "{}:verified".format(login)) else: signin(self) else: signin(self) 
  • Maybe the fact is that after calling set_cookie nothing else is done? Any answer to the client is worth returning. - Sergey Gornostaev
  • @SergeyGornostaev then it would not work for the first user in the file, but for him it works - Sasha
  • Try replacing the post method with get and see if the cookies are set. In your version, cookies are not set at all, even for the first line. - Avernial
  • @Avernial good, I will try - Sasha

0