开发者

Early Django Admin Logout

I'm working on a Django 1.2.3 project, 开发者_Go百科and I'm finding that the admin session seems to timeout extremely early, after about a minute after logging in, even while I'm using it.

Initially, I had these settings:

SESSION_COOKIE_AGE=1800
SESSION_EXPIRE_AT_BROWSER_CLOSE=True

I thought the problem might be my session storage was mis-configured, so I tried configuring my session to be stored in local memory by adding:

SESSION_ENGINE = "django.contrib.sessions.backends.cache"
CACHE_BACKEND = 'locmem://'

However, the problem still occurs. Is there something else that would cause admin sessions to timeout early even when the user is active?


Caching sessions in locmem:// means that you lose the session whenever the python process restarts. If you're running under the dev server, that would be any time you save a file. In a production environment, that will vary based on your infrastructure - mod_wsgi in apache, for example, will restart python after a certain number of requests (which is highly configurable). If you have multiple python processes configured, you'll lose your session whenever your request goes to a different process.

What's more, if you have multiple servers in a production environment, locmem:// will only refer to one server process.

In other words, don't use locmem:// for session storage.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜