Skip to main content
 首页 » 编程设计

python之Django、Apache 和 session

2025年05月04日20虾米姐

如何保证Apache重启(或停止再启动)后session不被清除?

因为当我升级我的源代码并重新启动 Apache 时,我刷新了网页,然后我必须重新登录。 session 丢失。

Session 存储在 Memcache 中。不知道它是如何以及为什么被清除的。如何保留 session ,使用户在 apache 重启后不需要登录?

请您参考如下方法:

根据Django documentation .

For persistent, cached data, set SESSION_ENGINE to "django.contrib.sessions.backends.cached_db". This uses a write-through cache – every write to the cache will also be written to the database. Session reads only use the database if the data is not already in the cache.