Normally, we set the开发者_开发问答 cookie with a single max_age
as following:
response.set_cookie('name1', 'value1', max_age=3600*24*365)
response.set_cookie('name2', 'value2', max_age=3600*24*365)
response.set_cookie('name3', 'value3', max_age=3600*24*365)
Note, we set the max_age
again and again. How to set a default max_age to all cookies that does not have a max_age parameter? Is there any configuration for it?
May be simple wrap set_cookie function:
def set_cookie(name, value, max_age=DEFAULT_MAX_AGE):
response.set_cookie(name, value, max_age)
精彩评论