Django:登录页面加载时在数据库中创建的会话 [英] Django: Session created in database when login page loaded

查看:97
本文介绍了Django:登录页面加载时在数据库中创建的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的django_session表越来越大,这似乎是由于我设置了pingdom僵尸程序击中了登录页面。我尝试创建一个全新的django 1.4应用程序,并且该行为在使用django.contrib.auth.views.login页面的任何页面上进行了复制,包括默认的管理员登录页面。

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?

(我将pingdom bot重定向到了一个不会导致创建新会话的页面,但是我想解决django

(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).

我在这里看到了这个问题巨大的Django会话表,正常行为还是错误?似乎不是同一个问题

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

推荐答案

稍作搜索后,我发现这是通过 set_test_cookie()方法。

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

在最新版本的Django(git main)中,它已被删除: https://github.com/django/django/commit/9d2c0a0ae6ce931699daa87735d5b8b20af9/ >

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

Fo暂时,我只建议您使用登录页面的修改版本,而不使用 set_test_cookie()方法。

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.

这篇关于Django:登录页面加载时在数据库中创建的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆