Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask - How to get a cookie expiration time?

I'd like to know how you can get the expiration time of a Flask cookie. For setting it, I have the following code:

resp.set_cookie('id', my_id
            expires = current_time + current_time + datetime.timedelta(days=30))

However, I am having difficulties getting that value back.

like image 571
user3276768 Avatar asked Oct 30 '22 11:10

user3276768


1 Answers

I think we cannot, according to Microsoft's explanation of how ordinary browsers work.

The browser is responsible for managing cookies, and the cookie's expiration time and date help the browser manage its store of cookies. Therefore, although you can read the name and value of a cookie, you cannot read the cookie's expiration date and time

https://msdn.microsoft.com/en-us/library/ms178194(v=vs.100).aspx

A question "How to get cookie's expire time" refers to the same problem, and the way of putting expiration date into a cookie's value is shown in one of the answers.

like image 120
tsuda7 Avatar answered Nov 08 '22 05:11

tsuda7