简体   繁体   中英

change tornado cookie secret while running

I need to change tornado cookie secret while its running. all the sample's define the secret code before start tornado server and I want to change cookie secret while my server running because I want to my server ignore all the cookie data saved before (expire cookie not do the job) and save new one's

Every RequestHandler class has a copy of the main settings under self.application.settings .

You can modify the settings before setting the cookies:

class MyHandler(web.RequestHandler):
    def change_cookie_secret(self):
        self.application.settings['cookie_secret'] = '<new secret>'

Call self.change_cookie_secret() method before you create cookies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM