top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to clear the DJANGO session cache ?

+1 vote
792 views

When a user logs in, Django adds a row to the django_session database table. Django updates this row each time the session data changes. If the user logs out manually, Django deletes the row. But if the user does not log out, the row never gets deleted.

posted May 8, 2014 by Mishthy Mukherjee

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

To understand this problem, consider what happens with the database backend. When a user logs in, Django adds a row to the django_session database table. Django updates this row each time the session data changes. If the user logs out manually, Django deletes the row. But if the user does not log out, the row never gets deleted. A similar process happens with the file backend.

Django does not provide automatic purging of expired sessions. Therefore, it’s your job to purge expired sessions on a regular basis. Django provides a clean-up management command for this purpose: clearsessions. It’s recommended to call this command on a regular basis, for example as a daily cron job.

Note that the cache backend isn’t vulnerable to this problem, because caches automatically delete stale data. Neither is the cookie backend, because the session data is stored by the users’ browsers.

so run:

$ ./manage.py clearsessions

answer May 9, 2014 by Saif Khanam
Similar Questions
+1 vote

Anyone can explain how to delete or alter existing table in database?

+2 votes
(venv)avinash@dell ~/django_projects/usertracking $ python manage.py runserver 113.193.144.56:80
Performing system checks...

System check identified no issues (0 silenced).
December 27, 2014 - 13:12:42
Django version 1.7.1, using settings 'usertracking.settings'
Starting development server at http://113.193.144.56:80/
Quit the server with CONTROL-C.
Error: That IP address can't be assigned-to.
+1 vote

I want to count the number of active user in website and also I have to display their IP Address by using python Django framework.

0 votes

Can anyone help me to generate SQL query from Django query

  • Like below:

Employee.objects.all() => select * from employee

0 votes

I'm new to Django. Is there any tell how to add a limit filter in Django?

...