开发者

session issue with django+apache+mod_wsgi

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 fi开发者_如何学运维x it?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜