Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same Domain iframe cookies

Tags:

php

cookies

I have an image uploader (http://valums.com/ajax-upload/) that uses an iframe as a fallback for processing. My site uses cookies to store the user information. Will the cookie with the user information be passed onto the iframe (I need to know the user's id when processing the images). The iframed pages is on the same domain as where the cookie is generated.

like image 706
Jason Small Avatar asked Jul 05 '11 05:07

Jason Small


People also ask

Can iframe share cookies?

Only the domain which created the cookie can read its cookie. So you have to read the cookie from within the iframe and then pass it to the parent window. If you don't have access or control over the page in the iframe then there is no way to get the cookie value.

Do IFrames set cookies?

Website content loaded in iframes from third party content providers like YouTube may set cookies and thereby require the visitor's prior consent. To hold back cookies until the website visitor has consented, Cookiebot will postpone loading the video until the visitor has consented.

How do I delete iframe cookies?

If the iframe is the same domain and the page with your javascript, then you can remove the iframe's cookie by setting the expiration date as you have indicated. But, you cannot prevent the iframe from setting that cookie again with its own javascript or via its own server.


2 Answers

Yes, if the iframe's source is the same domain as your parent page then any request originating from the iframe should send the same cookies.

Also, if you have Javascript being loaded into the iframe that should be able to access those domain's cookies as well.

like image 182
Abdullah Jibaly Avatar answered Oct 17 '22 21:10

Abdullah Jibaly


If you set cookies like:

set-cookie: some-key=some-value; path=/;

YES

but if you use something like:

set-cookie: some-key=some-value; path=/;
set-cookie: some-key=; path=/ajax-upload/;

NO

like image 39
TheHorse Avatar answered Oct 17 '22 23:10

TheHorse