Cookie not being sent in iframe in IE9

前端 未结 4 387
感情败类
感情败类 2021-01-31 17:50

First of all, I\'ve did some research before posting this question, so I know about the P3P Policy and the MSDN article about it. From what I understand, this policy mostly (if

相关标签:
4条回答
  • 2021-01-31 18:16

    If anyone is trying to solve this for a .NET Application

    Add a P3P header as Carlos mentioned

    HttpContext.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
    

    Edit: Even better, if you want to put this in Controller, simply add the following attribute

    public class IEP3PHeaderAttribute : FilterAttribute, IResultFilter
    {
        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // check if the user is using a IE based browser, add a p3p header if true and hasn't already been added
            if (HttpContext.Current.Request.Browser.Browser.ToUpper().Contains("IE"))
            {
                if (System.Web.HttpContext.Current.Response.Headers["p3p"] == null)
                {
                    HttpContext.Current.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");    
                }
            }
        }
    
        public void OnResultExecuted(ResultExecutedContext filterContext)
        {
        }
    }
    

    and then in your controller, e.g. HomeController

    [IEP3PHeader]
    public class HomeController
    {
       public ActionResult DoSomething() {};
       public ActionResult DoSomethingElse() {};
    } 
    
    0 讨论(0)
  • 2021-01-31 18:25

    Is this about the sequence in which the cookies are generated - i.e. does the GA cookie exist before the iframe is loaded, but the session cookie set when it's loaded?

    Where's the code?

    by changing the document.location property

    Are you assigning a value directly to the location object, or are you using location.replace() or location.href=...?

    0 讨论(0)
  • 2021-01-31 18:26

    Is this a correct reproduction of your test bed? http://www.coderun.com/ide/?w=EyTizeGw9kKgHjwNp3xiPw

    I'm getting cookies back in IE9, what am I missing?

    0 讨论(0)
  • 2021-01-31 18:39

    Have you tried adding the the P3P header? It is not as difficult as that article says.

    For example in PHP just add this header in the top of the php file:

    <?php
        header('p3p: CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM"');
    ?>
    

    This exact problem but in a diferent context worked here: Facebook app works on all browsers but not IE8

    0 讨论(0)
提交回复
热议问题