Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tornado secure cookie expiration (aka secure session cookie)

How can I set in Tornado a secure cookie that expires when the browser is closed?
If I use set_cookie I can do this without passing extra arguments (I just set the cookie), but how if I have to use set_secure_cookie?

I tried almost everything:

  • passing nothing: expiration is set to its default value, that is 1 month
  • passing an integer value: the value is considered as day, i.e. 1 means 1 day
  • passing a float value: it works, for example setting 0.1 it means almost one hour and a half
like image 965
Marco Risi Avatar asked Sep 12 '12 08:09

Marco Risi


People also ask

Does session cookie expire?

Session cookies expire once you log off or close the browser. They are only stored temporarily and are destroyed after leaving the page. They are also known as transient cookies, non-persistent cookies, or temporary cookies.

How long should a login cookie last?

If the website doesn't set the expiry date, the browser will delete the cookie once it's closed. The average lifetime of a cookie is about 30 days, but cookies can also be set to last for over a year.

What is cookie timeout?

The cookie has an Expire attribute that defines a specific date and time, after which the browser should stop sending the cookie and delete it.


1 Answers

It seems to me that you are really on the right track. You try lower and lower values, and the cookie has a lower and lower expiration time.

Pass expires_days=None to make it a session cookie (which expires when the browser is closed).

like image 150
Linus Thiel Avatar answered Sep 20 '22 19:09

Linus Thiel