David B
David B

Reputation: 61

How to detect browser cookie protection policies?

Is it possible to determine the user's browser cookie protection policies? Firefox and Safari both disable cross-site cookies for privacy protection:

https://blog.mozilla.org/en/products/firefox/firefox-rolls-out-total-cookie-protection-by-default-to-all-users-worldwide/

https://support.apple.com/en-ca/guide/safari/sfri40732/mac

This may cause some issues in rendering an iframe such as the Google Calendar Widget:

https://support.google.com/calendar/answer/10249848?hl=en

Is there a way to detect the cookie protection policy in JavaScript to optionally render a different element in place of the iframe?

Upvotes: 1

Views: 347

Answers (1)

pbz
pbz

Reputation: 11

Since Total Cookie Protection is enabled by default you can expect almost all Firefox users to have it enabled.

Otherwise, from within the 3rd-party iframe you can use the Storage Access API to find out if you have 1st-party storage access:

let hasStorageAccess = await document.hasStorageAccess();

This should work in both Firefox and Safari.

You can read more about state partitioning here: https://developer.mozilla.org/en-US/docs/Web/Privacy/State_Partitioning

If you're having trouble getting the Google Calendar widget to work in Firefox you can also file a bug here: https://bugzilla.mozilla.org/

Upvotes: 1

Related Questions