diff --git a/django/contrib/sessions/backends/file.py b/django/contrib/sessions/backends/file.py
index cb81534..024a193 100644
a
|
b
|
|
1 | 1 | import errno |
2 | 2 | import os |
3 | 3 | import tempfile |
| 4 | import time |
4 | 5 | |
5 | 6 | from django.conf import settings |
6 | 7 | from django.contrib.sessions.backends.base import SessionBase, CreateError |
… |
… |
class SessionStore(SessionBase):
|
50 | 51 | session_file = open(self._key_to_file(), "rb") |
51 | 52 | try: |
52 | 53 | file_data = session_file.read() |
| 54 | # The age of session file from last modify time |
| 55 | age = time.time() - os.path.getmtime(self._key_to_file()) |
| 56 | expired = age > settings.SESSION_COOKIE_AGE |
53 | 57 | # Don't fail if there is no data in the session file. |
54 | 58 | # We may have opened the empty placeholder file. |
55 | | if file_data: |
| 59 | if not expired and file_data: |
56 | 60 | try: |
57 | 61 | session_data = self.decode(file_data) |
58 | 62 | except (EOFError, SuspiciousOperation): |