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/
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章