class werkzeug.contrib.securecookie.SecureCookie(data=None, secret_key=None, new=True)
x = SecureCookie({"foo": 42, "baz": (1, 2, 3)}, "deadbeef")
x["foo"]
>>> 42
x["baz"]
>>> (1, 2, 3)
x["blafasel"] = 23
x.should_save
>>> True
参数 | 描述 |
---|
data | dict list tuples 或者none |
secret_key | 在serialize() 之前必须设置 |
new | The initial value of the new flag |
对象 | 描述 |
---|
new | 第一次创建cookie,为真 |
modified | 默认为True,可以更改 |
hash_method() | The hash method to use |
classmethod load_cookie(request, key=‘session’, secret_key=None) | Loads a SecureCookie from a cookie in request. If the cookie is not set, a new SecureCookie instanced is returned. |
classmethod quote(value) | Quote the value for the cookie. |
quote_base64 | True |
save_cookie(response, key=‘session’, expires=None, session_expires=None, max_age=None, path=’/’, domain=None, secure=None, httponly=False, force=False) | |
serialization_method | |
serialize(expires=None) | |
should_save | |
classmethod unquote(value) | |
classmethod unserialize(string, secret_key) | |
参考:
https://werkzeug-docs-cn.readthedocs.io/zh_CN/latest/contrib/securecookie.html