ie9 重定向后丢失 cookie [英] ie9 loses cookies after redirect

查看:24
本文介绍了ie9 重定向后丢失 cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 iframe:

I have an iframe that:

  1. 向服务器发送 post 请求
  2. 服务器返回 302 并设置 cookie
  3. 浏览器不保存 cookie 而是发一个帖子(不知道为什么不获取但没关系)
  4. #3 的 cookie 丢失了

我找到了一个解决方法:

i've found a workaround:

Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("Cache-Control", "no-cache");

但它没有帮助.mb 有人知道什么可以解决这个问题吗?

but it didn't help. mb anybody knows what can fix this issue?

推荐答案

您可能想了解为什么您的浏览器执行 POST 而不是 GET,因为这意味着您遗漏了一条重要的信息.没有浏览器会 遵循带有 POST 的 HTTP/302 重定向.

You may want to look into why your browser is doing a POST rather than a GET, since that implies that there's an important piece of information that you left out. No browser will follow a HTTP/302 redirect with a POST.

在 IE9 中,重定向响应被缓存 如果标头允许(IE8 及以下不会缓存重定向).

In IE9, redirection responses are cached if headers allow (IE8 and below would not cache redirects).

您绝对可以在 302 重定向上设置 cookie.这里有两种可能:

You can absolutely set a cookie on a 302 redirect. There are two possibilities here:

  1. 您的 cookie 被删除,因为您未能在响应中提供 P3P 标头,表明您的隐私惯例符合用户的需求.
  2. 您的重定向响应是从用户的缓存中提取的,而不是从服务器中提取的,并且缓存的响应没有设置 cookie.

鉴于您在 IFRAME 中遇到此问题,#1 似乎更有可能.(参见 快速浏览 P3P)

Given that you're having this problem in an IFRAME, #1 seems more likely. (See Quick Look at P3P)

这篇关于ie9 重定向后丢失 cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆