Django設定session的有效期
阿新 • • 發佈:2019-01-10
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/
你可以傳遞四種不同的值給它:
* 如果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/