Django设置session的有效期

request.session.set_expiry(value)

你可以传递四种不同的值给它:

* 如果value是个整数,session会在些秒数后失效。
* 如果value是个datatime或timedelta,session就会在这个时间后失效。
* 如果value是0,用户关闭浏览器session就会失效。
* 如果value是None,session会依赖全局session失效策略。
    * If value is an integer, the session will expire after that many seconds of inactivity. For example, calling request.session.set_expiry(300) would make the session expire in 5 minutes.
    * If value is a datetime or timedelta object, the session will expire at that specific date/time.
    * If value is 0, the user’s session cookie will expire when the user’s Web browser is closed.
    * If value is None, the session reverts to using the global session expiry policy.

原文:https://docs.djangoproject.com/en/1.5/topics/http/sessions/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章