【发布时间】: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 的日志:
- requestlog-chrome.har(忽略 cookie)
- requestlog-chrome.txt(忽略 cookie)
- requestlog-iron.har(保留 cookie)
- requestlog-iron.txt(保留 cookie)
有问题的 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