(cls)
| 207 | |
| 208 | @classmethod |
| 209 | def clear_expired(cls): |
| 210 | storage_path = cls._get_storage_path() |
| 211 | file_prefix = settings.SESSION_COOKIE_NAME |
| 212 | |
| 213 | for session_file in os.listdir(storage_path): |
| 214 | if not session_file.startswith(file_prefix): |
| 215 | continue |
| 216 | session_key = session_file.removeprefix(file_prefix) |
| 217 | session = cls(session_key) |
| 218 | # When an expired session is loaded, its file is removed, and a |
| 219 | # new file is immediately created. Prevent this by disabling |
| 220 | # the create() method. |
| 221 | session.create = lambda: None |
| 222 | session.load() |
| 223 | |
| 224 | @classmethod |
| 225 | async def aclear_expired(cls): |
no test coverage detected