Read IFrame cookie

12,225

It is impossible because of the same origin policy. Do you really want someone to be able to stick an iframe on any page, point to any domain, and get your cookies?

Share:
12,225
user847988
Author by

user847988

About me

Updated on June 04, 2022

Comments

  • user847988
    user847988 almost 2 years

    I created an iframe and I loaded a website in it ( i dont have access to this website - it wasnt written by me)

    <script type="text/javascript">
    
      var el = document.createElement("iframe");
      el.setAttribute('id', 'ifrm');
      document.body.appendChild(el);
      el.setAttribute('src', 'http://AWEBSITE.com/');
      alert(document.getElement("iframe").cookie); //This doesnt work.....
    </script>
    

    Can I use javascript in some way to read my cookies of the iframe?