IE Blocking iFrame Cookies

I got a call today about one of my applications not running correctly from inside an iFrame. I tried it out and it looked like everything worked great in Safari and Firefox but not IE6 or IE7. It took me a few failed attempts to fix it before I decided it must be a session problem. After firing up a packet sniffer it became obvious the cookie with the session ID was not being passed.

The problem lies with a W3C standard called Platform for Privacy Preferences or P3P for short. You can read all about the boring stuff via the link or else just install the P3P Compact Policy header below. This will allow Internet Explorer to accept your third-party cookie. You will need to send the header on every page that sets a cookie.

PHP:

header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

ASP.NET:

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

Django:

response = render_to_response('mytemplate.html')
response["P3P"] = 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'

JSP:

response.addHeader("P3P","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"")

On which side

Should the header function (I code php) be included on the page containing the IFrame or the page that's supposed to show inside the IFrame?

P3P Header in java

Hi,

I am setting up P3P header in the response by setting up filter on java side. But some how its not setting up the P3P header. What should i do. The filter code looks like below

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.setHeader("P3P",
"CP=\"ALL DSP COR CURa ADMa DEVa TAIa OUR IND UNI COM NAV INT CNT\"");
chain.doFilter(request, httpResponse);
}

Is there any other way to setup P3P header in java

Request

Hi, I am gettin same problem in asp.net, my frame is not saving the cookies. Can you send me the code how i can fix this problem on my Email ID please...
My Email ID : sarajeevraj@gmail.com

Thanks a lot! It fixed my

Thanks a lot! It fixed my problem! :)

Request

Hi, I am gettin same problem in asp.net, my frame is not saving the cookies. Can you send me the code how i can fix this problem on my Email ID please...
My Email ID : sarajeevraj@gmail.com

WHOA!

D00d, seriously! I would have never EVER fingered that one out on my own! MANY MANY thanks! Buy a beer on me!

-Dan

Adam: I would like to add to

Adam:

I would like to add to the chorus of praise. I'm sure you saved me HOURS of work, and I will take all the credit at my workplace :).

Thanks again.

Working Perfectly

Thanks Adam,

I applied your solution and it worked perfectly. You really saved me

Appreciated,
Ma'en

In aspx Probem

Respected,
I have a page aspx with an internal iframe that should receive pages called by menu of the type:

The iframe is .
In the firefox and chrome it perfectly works. And in IE8 it doesn't work, the page opens in another window.
It includes the directing HttpContext.Current.Response.AddHeader("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

in the load aspx-cs and it continues not working in IE.
I request help for that problem. Adim.
adim.almeida@globo.com

Complement

Respected,
In complement previus msg:

Menu:

Iframe:

Thanks! Adim

Phenomenal!

This is great work!

Thank You

Thanks Adam , It saved the Day

Many, many thanks!

Saved me from a huge headache.

thousand thanks.

thousand thanks.

Full PHP Code Anyone?

I'm looking for a quick copy-and-paste of what to put as the PHP code, but I'm not too keen on PHP myself. Here's what I've come up with from reading the comments:

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

I'm just needing to find the full code to see if the iframe issue with IE is the problem users are having on my site. Anyone want to paste the code they used? This one doesn't seem to do anything... :/

Hero

You are. That was becoming a serious pain in the neck until I found your fix - many thanks.

ailove

One day, the boy bentonite clay back to the bentonite powder and he looked sad. “Come and rheology modifiers with me,” the tree asked the Aluminosilicate. “I am no longer a kid, I don’t play around trees anymore.” The boy Aflatoxin Adsorbent, “I want toys. I need money to buy Wine Making Additive.”“Sorry, but I don’t have Diosmectite...but you can pick all my apples and sell them. So, you will have money.
” The boy was so excited. He modified bentonite all the apples on the tree and left happily. The boy never came back after he picked the apples. The tree was sad.

ailove

One hot Dioctahedral smectite day, the boy smecta and the tree was Clarifying Agent. “Come and play with me!” the Toxin Binder said. “I am sad and montmorillonite clay old. I want to go Bentonite to relax myself. Can you give me a calcium bentonite?”“Use my trunk to build your boat. You can sail far away and be happy.” So the boy cut the tree sodium bentonite to make a boat. He went sailing and never showed up for a long time. The tree was happy, but it was not true.

Thank you!

You save my day! Thanks a lot!

how to do this in a plain asp file

I have a web site that is just a plain .asp page. How would you put this in there. (sorry new to this). What about the page load issue with IE8? Any help would be appreciated

Thanks Adam, I applied your

Thanks Adam,

I applied your solution and it worked perfectly. You really saved me

Appreciated,Oyunlar

how to do this in a plain asp file

Did you get this resolved??? I have the same issue.

thanks

pure genius ! great job

You are the man

Thanks a lot for sharing that "beyong totally crazy" information !
You just saved my day too :)

third party cookie not working in iframe in ie due to security

Here's our issue...will this help???

We have the coolest interactive survey ever created and it requires a cookie to run it.
Works great in direct link or even redirect....www.normalmeter.com (interactive survey that tells you how normal you are in a relationship or single...super cool!!!)

Anyway Reader's Digest (80 million readers) put in the magazine and on the homepage today. Yes, this is a big deal and I will owe somebody hugely on a fix for this! So it's live on www.rd.com homepage, but if you have internet explorer and the default is set to medium or high security, it doesn't work! UGGGGGG! Figured I could cry or try to call out for help.

So, we need the cookie (which is third party via Reader's Digest iframe) and we need it to run on internet explorer without telling people with IE to set security to low. That's not an option.

We code can we put in the survey so it will run within the iframe and ie????

Feel free to email me directly or I will check back on this blog on the hour for answer.

mcnorthrup@yahoo.com

Take the cool survey and let me know what you think! It's really funny and gives fun payback.

www.normalmeter.com

xo Chrisanna

third party cookie not working in iframe in ie due to security

I meant to say which code can we put in survey so it will run with iframe via ie without this error:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
Page2.doGet(Page2.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:420)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:134)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.

IFrame not working in IE

I Have an asp.net application. I have added the P3P Policy as mentioned, but my page still gets refreshed wen i try to login. Below is my code....

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<% HttpContext.Current.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""); %>

Genius

You've a wonderful wonderful man. I'd protect you in prison.

Rails solution

response.headers['P3P'] = 'CP="NON DSP COR CURa IVAa IVDa CONa OUR NOR STA"'

What I did..

I had the same problem once, and the way I solved it was by using a proxy script, that way everything was dereferenced to my current domain and iframe cookies were no longer third party. :)

God bless you!

I was near to suicide when found your article. Thanks a lot, you're my Lord. (Die, IE, die!)

Ahhhhhh

I'm a novice programmer, more of a web site making feller. We're sending out a national campaign and needed to have a framed version of our website in another domain for a degree of separation. This of course made the cookies useless in IE7 until stumbling across this fix. I was only half an hour deep but it couldv'e been all day. Thank you so much!!!!

It's wonderful, small thing

It's wonderful, small thing made large difference. Thank you.

Thank you

Saved my day too! Thank you very much!

If you can see this, your

If you can see this, your browser doesn't
understand IFRAME. However, we'll still
link
you to the file.

More Free SelectSmart.com Widgets

IE8

This does not work in IE8

IE8

Hi, IE8 is not working me as well. Did you find a solution for it?

Thanks
Bharath

IE8

It works for IE8. I added this inside Page_Load method
HttpContext.Current.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

Btw, THANKS A LOT.

Thank you very much!

I was getting mad solving why my iframe facebook app won't work in IE. You are evil genius!

Thank you very much, you

Thank you very much, you saved my day!

This worked for us

This worked for us initially, but would not work with the following meta tag:

meta http-equiv="Content-Type" content="text/html; charset=utf-8"

I had to remove the meta tag, and set the content type with php:

header('Content-Type: text/html; charset=utf-8');

careful about 304 not modified responses

Even with the P3P header added, you can still get into trouble if IE7 submits a request for a cached page, and the response is 304 not modified. That header-only response does NOT include the P3P header element... and if it _also_ attempts to set a cookie, IE7 gets upset and destroys the cookie... and worse still, blocks the site.

So, I eventually fixed this problem by ensuring that no 304 not modified response was ever generated (by setting the etag anew w each response).

Thank you for this from my

Thank you for this from my friend Rasha.

Thanks!!!

you solve my problem so easy!!!

Generate P3P Policy

Thanks for the useful instruction :-)
I was using this in our dev site, but today I need to put it on our production site, so I learned how to generate a P3P policy as I think would be better to generate our own if using on production site, so here is the instruction if anybody needs to do so http://everydayopenslikeaflower.blogspot.com/2009/08/how-to-create-p3p-policy-and-implement.html

Dang! Thanks so much, it saved so much time!

I thought I was screwed when I checked IE and found my application wasn't keeping cookies set in iframes. Just one line saved the day! Thanks!

thanks!

i love it when theres such an easy fix!

Thanks

Thank you for this, I'm sure I would have been going around in circles for hours without this fix!

Awesome. Just awesome :P !

Awesome. Just awesome :P !

Thanks a lot

Thank you Very Much it's working just fine