是否有可能获得在JavaScript的HTTP响应报头中的Set-Cookie值? [英] Is it possible to get the Set-Cookie value from an HTTP response header in JavaScript?
问题描述
我使用 jQuery的阿贾克斯()
法做出一些异步服务器调用和要赶在那里呼叫失败,因为会话超时的情况。
I'm using jQuery's ajax()
method to make some asynchronous server calls and want to catch the case where a call fails because the session has timed out.
从看在这种情况下,响应头,我看到他们包括
From looking at the response headers in this case, I see that they include
Set-Cookie: SMSESSION=LOGGEDOFF
这似乎是一个pretty的可靠的测试。但调用 getAllResponseHeaders
传递给jQuery的误差
回调显然是返回一个空字符串,我无法搞清楚得到的报头信息的任何其他方式。 XMLHtt prequest
对象
which seems like a pretty reliable test. But calling getAllResponseHeaders
on the XMLHttpRequest
object passed to jQuery's error
callback apparently returns an empty string, and I'm having trouble figuring out any other way of getting that header information.
这可能吗?
推荐答案
如果该文件是从同一个域和路径,使用的document.cookie接口 如果cookie属性设置专用HTTP,它是人迹罕至
If the document is from the same domain and path, use the document.cookie interface If the cookie has the http-only attribute set, it's inaccessible
这篇关于是否有可能获得在JavaScript的HTTP响应报头中的Set-Cookie值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!