আমার পৃষ্ঠায় একটি ইফ্রাম আছে সাফারি তৃতীয় পক্ষের কুকিগুলিকে অবরুদ্ধ করে রেখে, আমি এখানে 'বিকাশকারী গাইডেন্স' এর অধীন প্রস্তাবিত স্টোরেজ অ্যাক্সেস এপিআই ব্যবহার করার চেষ্টা করছি: https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more / । আমি নথি থেকে নিম্নলিখিত কোডটি অনুলিপি করেছি :
<script type="text/javascript">
window.addEventListener('load', () => {
document.getElementById('test-button').addEventListener('click', () => {
document.hasStorageAccess().then(hasAccess => {
console.log('hasAccess: ' + hasAccess);
if (!hasAccess) {
return document.requestStorageAccess();
}
}).then(_ => {
console.log('Now we have first-party storage access!');
document.cookie = "foo=bar";
console.log(`document.cookie: ${document.cookie}`);
}).catch(_ => {
console.log('error');
});
});
});
</script>
<button id="test-button">Test</button>
ব্রাউজার কনসোল আউটপুট:
[Log] hasAccess: true
[Log] Now we have first-party storage access!
[Log] document.cookie:
আপনি দেখতে পাচ্ছেন, অনুদানটি সফল বলে মনে হচ্ছে তবে এখনও কুকি সেট করতে পারে না। কারও কি ধারণা আছে ভুল কি?
সাফারি সংস্করণ 13.0.1
সম্পাদনা: সাফারি 13.1 এ কনসোল আউটপুট:
[Log] hasAccess: false
[Log] error
দ্রষ্টব্য: এনক্লোজিং পৃষ্ঠাটি এই পৃষ্ঠার দিকে নির্দেশ করে একটি সহজ iframeট্যাগ src।
console.log('Now we have first-party storage access!');আসা thenএর requestStorageAccess()?