﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36506	sessions.backend.cache.SessionStore.clear_expired doesn't clean	Efe Öge	Efe Öge	"Hello,

We've been using Redis as cache backend for session storage. To clean up old sessions, we run the ""python manage.py clearsessions"" management command. This command internally calls the clear_expired method on the associated SessionStore. If clear_expired raises a NotImplementedError, the command catches it and raises a CommandError, indicating that the session backend doesn't support session cleanup. This behavior makes sense. https://github.com/django/django/blob/main/django/contrib/sessions/management/commands/clearsessions.py

However, in the case of the cache backend, the clear_expired method is currently just an empty function. https://github.com/django/django/blob/main/django/contrib/sessions/backends/cache.py#L140

I would therefore recommend either explicitly raising a NotImplementedError here, or implementing a (potentially slow) cleanup mechanism that actually removes expired sessions.
What are your thoughts on this? If this looks like a bug to you, I’d be happy to help by sending a patch."	Bug	closed	contrib.sessions	5.2	Normal	wontfix			Unreviewed	0	0	0	0	0	0
