Commit 3b67bd3b authored by ibuler's avatar ibuler

[Update] 修复浏览器关闭后session不失效的问题

parent bb235f3e
...@@ -5,6 +5,7 @@ import re ...@@ -5,6 +5,7 @@ import re
import pytz import pytz
from django.utils import timezone from django.utils import timezone
from django.shortcuts import HttpResponse from django.shortcuts import HttpResponse
from django.conf import settings
from .utils import set_current_request from .utils import set_current_request
...@@ -56,6 +57,7 @@ class RequestMiddleware: ...@@ -56,6 +57,7 @@ class RequestMiddleware:
def __call__(self, request): def __call__(self, request):
set_current_request(request) set_current_request(request)
response = self.get_response(request) response = self.get_response(request)
if not settings.SESSION_EXPIRE_AT_BROWSER_CLOSE:
age = request.session.get_expiry_age() age = request.session.get_expiry_age()
request.session.set_expiry(age) request.session.set_expiry(age)
return response return response
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment