Home > ASP.net, php > IE7 iframe and cookie hell!

IE7 iframe and cookie hell!

February 19th, 2009

Recently I was working on a project which loads a third party domain webpage in an iframe. Everything looked fine except it started acting weird in Internet Explorer 7.

Later I realised that it was because of the default privacy settings (or rather annoyance) in IE7 which blocks third party cookies in iframes.

There are two ways to solve this.

  1. Change the IE7 settings to accept all cookies. This can be done by navigating to

Internet Options >> Privacy >> Advanced >> Check “Override Automatic Cookie Handling” and “Always allow session cookies”.

This solution is not possible if you are the webdeveloper. You cannot ask all users to change their privacy settings. So how can you over come this programatically? Look at the second solution.

 

     2. If you are the we developer then you can add p3p headers to the pages loaded in iframe. By doing this we are telling the browser that it is OK to create and maintain cookie values of the pages loaded in iframe. Adding the headers is not a tedious task. Use the following code.

PHP :

header('P3P: CP=\"IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA\"');

ASP :

Response.AddHeader "p3p", "CP=" & chr(34) & "CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR" & chr(34)

ASP.net :

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

:>

[Post to Twitter]   [Post to Plurk]   [Post to Digg]   [Post to ping.fm]

Related posts

Shoban ASP.net, php

  1. Rob MacDonald
    December 14th, 2009 at 17:40 | #1

    Does anyone know of a way of addressing this issue when you don’t have access to change the 3rd party web pages which you’re pulling into the iframe?

  2. December 15th, 2009 at 03:17 | #2

    @Rob

    Only option is to change clientt’s web browser settings.

  1. April 17th, 2009 at 01:48 | #1