Search code examples
ioscookiesmobile-safari

Can a webpage in mobile Safari check whether Settings > Safari > Accept Cookies 'From visited' or 'Always' is selected?


Is there a JavaScript function or something that iOS provides so that I can check how strict the cookie setting is from a webpage?

If there isn't something that iOS provides, is there an industry standard process for detecting which setting is being used? My initial idea is to drop a cookie and check whether it's there...but I was wondering whether there is a better way.


Solution

  • I highly suspect that there is no way to determine what the user's actual setting is, but Mobile Safari responds to navigator.cookieEnabled. The default for Mobile Safari (and even desktop Safari) is "From Visited". So if you are interested in 3rd party tracking via Cookies you may be out of luck, unless you find a way to bypass it (Google evidently did) or alert the user to change their setting to 'Always' (the fair/ethical route). I would say you are on to a reasonable and simple idea by setting a cookie from the 3rd party site and then checking if it is in fact there and then acting upon the result.

    Lots of information in this SO post, Safari 3rd party cookie iframe trick no longer working?

    And an interesting read from Gruber, http://daringfireball.net/2012/02/cookies_and_privacy