Create and delete cookies in an iframe with IE

Internet Explorer shines yet again… I had to write a login sync for two sites (Single sign-on).  So that you can log into one site and (behind the scenes) get logged into the other site.  I chose to do this with iframes and all was happy.  Until I had to verify that it worked in IE.  IE chooses to dismiss cookies set/removed through the iframe.  Setting a header on the page that creates/deletes the cookies will remedy this, though. 

Add this to your pages that create/delete the cookies:

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

It creates a p3p "compact policy" that gets sent to the client. This convinces IE to accept the cookie in some magical way…

Via articles on Asp.Net Resources and SalesForce

One thought on “Create and delete cookies in an iframe with IE

  1. Just wanted to say thanks for this post from a year ago: My fix for "Validation of viewstate MAC failed" error in IE. Saved me a lot of troubleshooting.

Comments are closed.