set_cookie(key, value='', max_age=None, expires=None, path='/', domain=None, secure=None, httponly=False)
Sets a cookie. The parameters are the same as in the cookie Morsel object in the Python standard library but it accepts unicode data, too.

Parameters:

key – the key (name) of the cookie to be set.
value – the value of the cookie.
max_age – should be a number of seconds, or None(default) if the cookie should last only as long as the client’s browser session.
expires – should be a datetime object or UNIX timestamp.
domain – if you want to set a cross-domain cookie. For example, domain=".example.com" will set a cookie that is readable by the domain www.example.com, foo.example.cometc. Otherwise, a cookie will only be readable by the domain that set it.
path – limits the cookie to a given path, per default it will span the whole domain.

1.

response = make_response(jsonify(success=True))
response = make_response(redirect(url_for("index")))
response = make_response(render_template("xxx.html"))

2.

set_cookie的参数，key, value=’’, max_age=None, expires=None, path=’/‘, domain=None, secure=None, httponly=False，其他的都好理解，我扯一扯max_age和expires。

max_age – should be a number of seconds, or None(default) if the cookie should last only as long as the client’s browser session.
expires – should be a datetime object or UNIX timestamp.

max_age需要int作为秒，它会计算多少秒后，设为过期；

expires需要datetime或timestamp作为值，再计算过期时间。

import datatime, time
def How_Much_Time(seconds=0, minutes=0, hours=0):
""" 将s、m、h后的时间转化为Y-m-d """
dt = datetime.datetime.now() + datetime.timedelta(seconds=int(seconds), minutes=int(minutes), hours=int(hours))
return dt.strftime("%Y-%m-%d")
def Date2Seconds(date):
""" 将Y-m-d后的时间转化为s(当前时间多少秒)  """
d = datetime.datetime.strptime(date,"%
Y-%m-%d")
return time.mktime(d.timetuple()) - time.time()

The End.