I can't set cookies on Tornado/Python

237 views
Skip to first unread message

Rodrigo Mariano

unread,
Nov 4, 2017, 7:05:23 PM11/4/17
to Tornado Web Server
Hello everyone,

I am with a problem that I am not understand the why... Basically I can't set cookies on Tornado/Python, either normal cookie or secure cookie. Below is my code:

    class API(BaseHandler):
   
        def get(self):
   
            self.set_secure_cookie("a_cookie", "a_value")
            a_cookie = self.get_secure_cookie("a_cookie")
   
            print(">>> a_cookie ", a_cookie)
   
            self.set_cookie("a_cookie", "a_value")
            a_cookie = self.get_cookie("a_cookie")
   
            print(">>> a_cookie ", a_cookie)

The output is:

    >>> a_cookie  None
    >>> a_cookie  None

The class BaseHandler extends the tornado.web.RequestHandler.

About the secure cookie, I set the cookie_secret.

I am not understanding the reason of when I set a cookie, I can't get it. I believe that I'm following the rules on sites (http://www.tornadoweb.org/en/stable/guide/security.html , https://technobeans.com/2012/08/07/tornado-cookies/)

(PS: I put this issue on StackOverFlow too [ https://stackoverflow.com/questions/47116421/i-cant-set-cookies-on-tornado-python ])

Thanks in advance.

Rodrigo


Pierce Lopez

unread,
Nov 4, 2017, 7:20:31 PM11/4/17
to rodmar...@gmail.com, python-...@googlegroups.com

- Pierce


--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rodrigo Mariano

unread,
Nov 5, 2017, 7:15:31 AM11/5/17
to Tornado Web Server
Thank you so much Pierce. The links really helped me. :D

Regards,

Rodrigo

- Pierce


To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages