2017-09-25 33 views
1

只有當我在設置文件中設置SESSION_SERIALIZER = "django.contrib.sessions.serializers.PickleSerializer"時,它纔有效。如何在django> = 1.6中指定會話的到期時間?

這裏是我的代碼:

... 
    tz = timezone.utc 
    expire_time = timezone.datetime.utcfromtimestamp(oa_token_expire_time).replace(tzinfo=tz) 
    request.session.set_expiry(expire_time) 
... 

回答

0

項目settings.py把會話過期值。例如:

SESSION_COOKIE_AGE = 300 

將在300秒內

到期
+0

@AlvinChiu,你試過嗎?它有效嗎? –