Django Book 翻译
菜单>:
TOC
返回
原文:
.. table:: Table 12-1: Cookie options +-----------+---------+------------------------------------------------------------+ |Parameter |Default |Description | +===========+=========+============================================================+ |``max_age``|``None`` |Age (in seconds) that the cookie should last. If this | | | |parameter is ``None`` , the cookie will last only until the | | | |browser is closed. | +-----------+---------+------------------------------------------------------------+ |``expires``|``None`` |The actual date/time when the cookie should expire. It needs| | | |to be in the format ``"Wdy, DD-Mth-YY HH:MM:SS GMT"`` . If | | | |given, this parameter overrides the ``max_age`` parameter. | +-----------+---------+------------------------------------------------------------+ |``path`` |``"/"`` |The path prefix that this cookie is valid for. Browsers will| | | |only pass the cookie back to pages below this path prefix, | | | |so you can use this to prevent cookies from being sent to | | | |other sections of your site. | | | | | | | |This is especially useful when you dont control the top | | | |level of your sites domain. | +-----------+---------+------------------------------------------------------------+ |``domain`` |``None`` |The domain that this cookie is valid for. You can use this | | | |parameter to set a cross-domain cookie. For example, | | | |``domain=".example.com"`` will set a cookie that is readable| | | |by the domains ``www.example.com`` , ``www2.example.com`` , | | | |and ``an.other.sub.domain.example.com`` . | | | | | | | |If this parameter is set to ``None`` , a cookie will only be| | | |readable by the domain that set it. | +-----------+---------+------------------------------------------------------------+ |``secure`` |``False``|If set to ``True`` , this parameter instructs the browser to| | | |only return this cookie to pages accessed over HTTPS. | +-----------+---------+------------------------------------------------------------+
翻译:
.. table:: 表 12-1: Cookie 选项 +-----------+---------+------------------------------------------------------------+ |参数 |缺省值 |描述 | +===========+=========+============================================================+ |``max_age``|``None`` |cookies的持续有效时间(以秒计),如果设置为 ``None`` cookies| | | |在浏览器关闭的时候就失效了。 | +-----------+---------+------------------------------------------------------------+ |``expires``|``None`` |cookies的过期时间,格式: ``"Wdy, DD-Mth-YY HH:MM:SS GMT"`` | | | |如果设置这个参数,它将覆盖 ``max_age`` 参数。 | +-----------+---------+------------------------------------------------------------+ |``path`` |``"/"`` |cookie生效的路径前缀,浏览器只会把cookie回传给带有该路径的页| | | |面,这样你可以避免将cookie传给站点中的其他的应用。 | | | | | | | |当你的应用不处于站点顶层的时候,这个参数会非常有用。 | +-----------+---------+------------------------------------------------------------+ |``domain`` |``None`` |cookie生效的站点。你可用这个参数来构造一个跨站cookie。如, | | | |``domain=".example.com"`` 所构造的cookie对下面这些站点都是可| | | |读的: ``www.example.com`` 、 ``www2.example.com`` 和 | | | |``an.other.sub.domain.example.com`` 。 | | | | | | | |如果该参数设置为 ``None`` ,cookie只能由设置它的站点读取。 | +-----------+---------+------------------------------------------------------------+ |``secure`` |``False``|如果设置为 ``True`` ,浏览器将通过HTTPS来回传cookie。 | +-----------+---------+------------------------------------------------------------+
备注:
译者: