Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!