To set a cookie in Tornado, you can use the set_cookie() method of the RequestHandler class. Here's an example:
main.py196 chars8 linesThe set_cookie() method takes two arguments: the name of the cookie and its value. You can also pass additional parameters to customize the cookie, such as an expiration time:
main.py323 chars10 linesIn this example, the expires parameter is set to one hour from now using the datetime module.
Note that when you set a cookie in Tornado, it is automatically sent as a Set-Cookie header in the HTTP response.
gistlibby LogSnag