Saturday, September 25, 2010

IE Blocking iframe Cookies

One of my web applications in PHP is running correctly inside iFrame. I tested the same iFramed PHP page on Safari and Firefox and everything works well but not in not IE6, IE7 or IE8. After trying a few times, the cookie using sessions to keep data was not being saved.
After Google-ing and thanks to Adam Young, found out that the problem lies with a W3C standard called Platform for Privacy Preferences or P3P for short. You can read all about the it at 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\"")

0 comments: