【问题标题】:Django Session gets expiredDjango 会话过期
【发布时间】:2014-09-19 06:22:07
【问题描述】:

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

例如,主域是“https://test.test.com”,假设当我以“https://test.test.com/analysis”打开我的第一个 django 项目并使用它在新选项卡中打开的界面中的 href“https://test.test.com/result”从它转到第二个项目时但是当我尝试对我的第一个项目“https://test.test.com/analysis”进行任何操作时,会话就会过期。

【问题讨论】:

标签: python django session


【解决方案1】:

看看 django 文档 (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.

【讨论】:

    【解决方案2】:

    您可以对某些 url 使用 SESSION_COOKIE_PATH,但 session 只适用于那些或类似的 url 等。SESSSION_COOKIE_PATH='/foo',然后它只适用于 '/foo/'、'/foobar' 等。

    【讨论】:

      猜你喜欢
      • 2016-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-01
      • 2023-04-06
      • 2012-04-29
      • 2021-09-02
      • 1970-01-01
      相关资源
      最近更新 更多