Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome cross domain cookie issue with iframe

I know this has been asked a few times, but on all the answers I found there was someone asking if it would still work and somebody else saying that it doesn't, so I was wondering if there is a solution to this problem that still works with the latest version of chrome:

Lets say we have website with an iframe embedded in it, the iframe source is from another host. The page inside the iframe needs cookies to work, but Google Chrome seems to refuse to set cookies that are set within the iframe. (This only happens when "block 3rd party cookies" is checked which seems to be happening on its own because I have multiple reports from different users who didn't touch the advanced options)

I have control over both of the sites, though I can only modify the html on the page that contains the iframe, no server side stuff.

Things I have tried so far that didn't work: Emedding an image from the same host as the iframe's source making a post request to the iframe setting up a P3P header

I can also send messages using xdm, though I don't know if that could help.

If anyone has any further ideas it would be greatly apreciated! I feel like there must be a solution to this problem somewhere

like image 335
hawk Avatar asked Dec 11 '13 16:12

hawk


1 Answers

Setting cookies inside an iFrame can be troublesome. However, iFrame can access cookies set outside the iFrame. You can show the page in a popup window which sets the necessary cookies (like authentication, etc) and then access these cookies from within the iFrame.

This is very helpful in case you want to authenticate user on some other domain. Just show a popup, authenticate and set cookies, then access these cookies on your site from iFrame.

like image 176
Sam Avatar answered Oct 05 '22 02:10

Sam