Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

304
Visualizações
Get cookie of parent page (iframe) using JS

I need to get a cookie created in parent page.

enter image description here

I need get a spesific cookie (example) who was cread on modiface--locatelcolomia.myvtex.com and used this on my child page modiface.locatelcolobmia.com (this one is called by vtex iframe)

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Thanks for the help, this is the answer: I got the cookie by Jquery and save on a input type hidden at the end send to my iframe calling a php page and send this value by URL (GET).

jQUERY

let cartId = $('#idCartInput').val();

IFRAME

("#idCartBtn").html("<iframe src='http://localhost:81/projectExample/modiface/index.php?cartId="+cartId+"' class='frameModiface' id='pruebasId' allow='camera' name='iframe_a'></iframe>");
about 4 years ago · Juan Pablo Isaza Relatório

0

You cannot directly get cookies from other pages.

You can send a request to that page to send the cookies.

getCookies.php (put on parent page)

window.onload = function(){document.getElementById('submitpost').submit();}
<?php if(!isset($_COOKIE['COOKIE_NAME_HERE']) {die('set cookie');} ?>

<h3>Please wait</h3>

<form id="submitpost" action="PUT_PREVIOUS_PAGE_URL_HERE" method="post">
  <input type="hidden" name="cookie" value="<?php echo $_COOKIE['COOKIE_NAME_HERE']; ?>">
</form>

Then set the cookie to that. Redirect users without the set cookie to the getCookies.php page.

This form can be intercepted and changed, but cookies can as well. Never put account details in cookies.

This answer requires a web server with PHP, chances are that your host does support PHP.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda