开发者

How to set all cookies with a single max_age in pylons?

开发者 https://www.devze.com 2023-01-15 02:13 出处:网络
Normally, we set the开发者_开发问答 cookie with a single max_age as following: response.set_cookie(\'name1\', \'value1\', max_age=3600*24*365)

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消