【问题标题】:Internet Explorer 9 and Chrome don't handle set-cookie headersInternet Explorer 9 和 Chrome 不处理 set-cookie 标头
【发布时间】:2011-10-28 13:04:27
【问题描述】:

我正在测试我的网站,该网站在 Iron、Firefox 和 Opera 上运行良好,现在使用 Internet Explorer 9 和 Chrome。它在每个浏览器中设置了两个重要的 cookie,除了 IE9 和 Chrome。这些浏览器似乎忽略了 set-cookie 标头。在我降低安全和隐私设置之前,Internet Explorer 中也缺少 Facebook 的 cookie(除了来自 skype.com 的 cookie,IE 中根本没有任何 cookie)。

cookie 是为域 modern-iq.appspot.com 设置的(此项目的 alpha 版本可通过 http://modern-iq.appspot.com 访问)。它不包含下划线,在我看来符合标准。

独立于实际路径,我总是为我的 cookie 选择“/”。 域始终是modern-iq.appspot.com(没有跨域cookie)。没有 iframe。

更新:我做了以下测试:

工作

  • Ubuntu(64 位)上的 Iron 12.0.750.0 (88853):cookie 工作
  • Ubuntu(64 位)上的 Firefox 6.0:cookie 工作
  • Windows XP 上的 Firefox 3.6.13:cookie 工作
  • Windows 7 上的 Firefox(未知版本):cookie 工作

不工作

  • Windows 7 上的 Internet Explorer 9:cookie 不起作用
  • Windows XP 上的 Chrome 13.0.782.112 m:cookie 不起作用

更新:请求失败的 Chrome 和工作 Iron 的日志:

有问题的 cookie 是请求链末尾的 fb_user 和 fb_access_token。

set_cookie 调用(Python):

set_cookie(self.response, FACEBOOK_USER_COOKIE_NAME, str(profile["id"]), domain='modern-iq.appspot.com',
                   expires=time.time() + COOKIE_EXPIRY_SPAN) #30 * 86400)
set_cookie(self.response, FACEBOOK_ACCESS_TOKEN_COOKIE_NAME, str(access_token), domain='modern-iq.appspot.com',
                   expires=time.time() + COOKIE_EXPIRY_SPAN) #30 * 86400)

set_cookie (Python):

def set_cookie(response, name, value, domain=None, path="/", expires=None):
    """Generates and signs a cookie for the give name/value"""
    for domain in domain, : #'localhost':
        logging.info('DOING COOKIE OF DOMAIN '+repr(domain)+'...')
        timestamp = str(int(time.time()))
        value = base64.b64encode(value)
        signature = cookie_signature(value, timestamp)
        cookie = Cookie.BaseCookie()
        cookie[name] = "|".join([value, timestamp, signature])
        cookie[name]["path"] = path
        if domain: cookie[name]["domain"] = domain
        if expires:
            cookie[name]["expires"] = email.utils.formatdate(
                expires, localtime=False, usegmt=True)
        response.headers._headers.append(("Set-Cookie", cookie.output()[12:]))

【问题讨论】:

  • 我认为问题本身与 Facebook 无关。这是一个 Cookie 问题。
  • 我添加了IE隐私报告的截图。它表明所有 cookie 都被接受。但是如果是这样的话,为什么IE不发送呢??

标签: google-app-engine google-chrome cookies internet-explorer-9


【解决方案1】:

您需要设置一个反映与 cookie 相关的隐私政策的 P3P 标头。 http://blogs.msdn.com/b/ieinternals/archive/2010/06/05/understanding-internet-explorer-cookie-controls.aspx

【讨论】:

  • 没有与我的 cookie 相关的特殊隐私政策。出于测试目的,我降低了 IE 中的所有安全和隐私设置。但它仍然不起作用。有什么想法吗?
  • 我的测试应用在 iframe 之外。没有。
  • 这与 IFRAMES 无关——IE 需要跨域 cookie 的 P3P 标头。您应该修改您的问题以完整描述您的设计,包括哪些代码在哪里运行。
  • 设计并不复杂。一切都在modern-iq.appspot.com 上运行。没有 iframe,没有跨域。单域。
  • 请提供网络捕获 (www.fiddler2.com) 或更改您的演示页面,以便不需要帮助您的人向您公开他们的网络和墙。
猜你喜欢
  • 2011-06-16
  • 1970-01-01
  • 2015-09-12
  • 1970-01-01
  • 2018-09-16
  • 1970-01-01
  • 2012-07-29
  • 2012-08-27
  • 1970-01-01
相关资源
最近更新 更多