magine
V2EX  ›  Django

又遇到坑了 SESSION_EXPIRE_AT_BROWSER_CLOSE 不支持 chrome

  •  
  •   magine ·
    Ma233 · Aug 28, 2014 · 6336 views
    This topic created in 4287 days ago, the information mentioned may be changed or developed.
    因为web应用会跑在公共电脑上,所以本来是希望用户关闭浏览器后必须重新登陆的。

    设置 SESSION_EXPIRE_AT_BROWSER_CLOSE = True

    结果在chrome下测试和firefox下结果不同!

    去官网查文档https://docs.djangoproject.com/en/1.5/topics/http/sessions/#browser-length-sessions-vs-persistent-sessions
    得到如下:

    Some browsers (Chrome, for example) provide settings that allow users to continue browsing sessions after closing and re-opening the browser. In some cases, this can interfere with the SESSION_EXPIRE_AT_BROWSER_CLOSE setting and prevent sessions from expiring on browser close. Please be aware of this while testing Django applications which have the SESSION_EXPIRE_AT_BROWSER_CLOSE setting enabled.
    Supplement 1  ·  Aug 28, 2014
    会在公共电脑被访问,不是服务器运行在公共电脑……
    Supplement 2  ·  Aug 28, 2014
    会在公共电脑被访问,不是服务器运行在公共电脑……
    2 replies    2014-08-29 09:17:14 +08:00
    can
        1
    can  
       Aug 29, 2014
    是设置成false吧?
    magine
        2
    magine  
    OP
       Aug 29, 2014
    @can
    默认是False,但是我希望关闭浏览器cookie就过期,所以要设置成True
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4997 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 04:03 · PVG 12:03 · LAX 21:03 · JFK 00:03
    ♥ Do have faith in what you're doing.