Django Session过期了

时间:2014-09-19 06:22:07

标签: python django session

我遇到了与Django会话相关的问题。我有一个与另一个Web应用程序集成的Web应用程序。我想运行具有相同域名的两个应用程序,但是当我运行第一个应用程序并从第一个UI打开第二个应用程序时,会话将过期第一个应用程序。

例如,主域名是" https://test.test.com"并假设当我打开我的第一个django项目" https://test.test.com/analysis"并使用href" https://test.test.com/result"从它进入第二个项目;来自界面它在新标签页面中打开但当我尝试对我的第一个项目进行任何操作时#34; https://test.test.com/analysis"会话过期了。

2 个答案:

答案 0 :(得分:2)

查看django docu(https://docs.djangoproject.com/en/1.5/topics/http/sessions/

我认为这是你需要的部分:

SESSION_COOKIE_PATH
Default: '/'

The path set on the session cookie. This should either match the URL path of your Django installation or be parent of that path.

This is useful if you have multiple Django instances running under the same hostname. They can use different cookie paths, and each instance will only see its own session cookie.

答案 1 :(得分:1)

您可以将SESSION_COOKIE_PATH用于某个网址,但会话仅适用于那些或类似的网址等.SESSSION_COOKIE_PATH =' / foo',那么它只适用于' / foo /&# 39;,' / foobar'等。