Jump to content

Access cookie of parent domain


NotionCommotion

Recommended Posts

I expected the following script to display a single cookie on the main page (cookie_2, and both the main page cookie and the subdomain cookie (cookie_3) within the iframe.

 

In actuality, the main page was as expected, but the iframe only displays cookie_3.

 

Can anyone explain what I am witnessing, and why the subdomain wouldn't be able to access the cookie set in the parent?

<?php
setcookie("cookie_".count(explode('.', $_SERVER['HTTP_HOST'])), 'Hello from '.$_SERVER['HTTP_HOST']);
echo('<pre>'.print_r($_COOKIE,1).'</pre>');
?>

<iframe src="http://test.mysite.com/testing/cookietest.php"></iframe>
Link to comment
https://forums.phpfreaks.com/topic/292814-access-cookie-of-parent-domain/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.