Django: Session created in database when login page loaded

[亡魂溺海] 提交于 2019-12-12 04:47:17

问题


My django_session table was growing very large and it seems to be due to a pingdom bot that I set-up hitting my login page. I tried creating a brand new django 1.4 app and the behaviour is replicated on any page that uses the django.contrib.auth.views.login page, including the default admin login page.

This surely can't be the desired behaviour. Is it a bug? Is there a fix?

(I have redirected the pingdom bot to another page that doesn't cause a new session to be created but I'd like to solve the django issue itself too).

I have seen the question here Huge Django Session table, normal behaviour or bug? and it doesn't seem to be the same issue


回答1:


After a little bit of searching I found that this is done by the login view (line 55) in the set_test_cookie() method.

In the latest version of Django (git main) it has been removed however: https://github.com/django/django/commit/9d2c0a0ae6ce931699daa87735d5b8b2afaa20f9#django/contrib/auth/views.py

For the time being I would simply recommend you to use a modified version of the login page which doesn't use the set_test_cookie() method.



来源:https://stackoverflow.com/questions/17098142/django-session-created-in-database-when-login-page-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!