Safari can not get cookies in iframe

I have two websites, one is A and the other is B. A embeds B through an iframe, and B obtains the data passed by A through a URL, such as lang=en. B can obtain lang through a URL, and then set it through Cookies.set ('lang ', urlLang, {secure: true, sameSite:'Nome'). When reading it, I cannot read Cookies.get ('lang '). Chrome and Edge can be read normally

A website's code

<iframe src="https://xxxxB.com/?lang=en"

B website's code is :

<script>
let params = new URLSearchParams(window.location.search)
let urlLang = params.get("lang")
console.log("urlLange:",urlLang)
document.getElementById("urlLang").innerHTML = "url language is :"+urlLang;
Cookies.set('lang', urlLang, { secure: true,sameSite: 'None'})
let lang = Cookies.get('lang');
console.log('Language:', lang);
document.getElementById("lang").innerHTML = "after cookies setting is:"+lang;

</script>

MacBook Pro 16″

Posted on May 13, 2025 7:45 PM

Reply

There are no replies.

Safari can not get cookies in iframe

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.