session issue with django+apache+mod_wsgi

社会主义新天地 提交于 2019-12-06 14:21:33

问题


I've written a django application, and put it on a CentOS server. It is definitely okay when I use django development web server.

Such as I start it by "python ./manage.py runserver", and access that server from browser on another computer. I can sign in one time, and access all the pages without issues.

However when I run it with apache+mod_wsgi, I just found I have to login with user and password time by time. I think maybe there is some problem with the session middleware, so, how can I find the root cause and fix it?


回答1:


There are a couple of different options for this.

In order of likelyhood (imho):

  • The session backend uses the cache system to store the sessions and you're using the locmem cache backend
  • The session backend isn't storing the cookies (secure cookies enabled? cookie timeouts? incorrect date on the server?)
  • The session middleware might not be loaded (custom settings for production server?)

Storing the session in the cache is only a good solution if you use memcached as the cache backend. So if you're storing the sessions in cache, make sure you use memcache :)

Either way, check if SESSION_ENGINE is set to django.contrib.sessions.backends.db



来源:https://stackoverflow.com/questions/4421114/session-issue-with-djangoapachemod-wsgi

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