python - Django does session.flush() expire the database session entry? -


this question has answer here:

according django documentation here

request.session.flush()

deletes current session data session , deletes session cookie. (django.contrib.auth.logout() function calls it)

but automatically expire session entry inside database table?

because if doesnt, think might cause unnecessary build of non-usable non-expired sessions inside table.

yes, does. if @ source docstrings explicitly state that:

def flush(self):     """     removes current session data database , regenerates     key.     """     self.clear()     self.delete()     self._session_key = none 

that being said, there build of expired sessions. that's why should set scheduled job clear them using clearsessions management command:

django not provide automatic purging of expired sessions. therefore, it’s job purge expired sessions on regular basis. django provides clean-up management command purpose: clearsessions. it’s recommended call command on regular basis, example daily cron job.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -