iOS 11 embedded Safari changes

AI-generated summary

In a discussion about iOS 11’s embedded Safari changes, david reports that Safari View Controller no longer shares cookies with Safari, causing users to log in separately in the Discourse app even if already logged in via Safari. This is an intentional Apple change, not a beta bug. While inconvenient on first use, cookies persist across app restarts afterward. A potential benefit is reducing the occurrence of a known logout bug linked here. Apple offers SFAuthenticationSession as an alternative for shared authentication, but it’s geared toward initial login, not ongoing session use. David suggests a possible workaround: using SFAuthenticationSession to authenticate via Safari cookies, then transferring session cookies into the app’s cookie store. Separately, he notes that image uploads still work as JPG in the current beta, contrary to earlier concerns linked here. sam enthusiastically welcomes the change, calling the previous logout bug “infuriating,” and confirms the team will consider solutions using Apple’s new API but doesn’t expect to prioritize fixes for 2–3 months.

I recently updated my iPhone to the public beta of iOS 11, and noticed an annoying change which impacts the Discourse app. I’m not sure there’s actually much we can do about it, so this is more of a heads-up. This is not a bug in the beta, it is an intended change from Apple.

A “Safari View Controller” instance no longer shares cookies with Safari. This means if you’re logged into discourse in safari, you will not be automatically logged in when you use the app.

Once you log in within the app, the cookies are persisted across app restarts, so it’s only an issue on first use.

One advantage of this is that it will probably reduce/stop the occurance of this bug

Apple has provided an alternative system for shared cookies, “SFAuthenticationSession”. I believe this is designed for initial authorisation though, rather than long term use to actually access a website.

The only potential solution I can think of is that the app uses SFAuthenticationSession to let the user authenticate using Safari cookies, then somehow loads some session cookies into the app’s own cookie store…


On a related note, this issue is not present in the current beta (as predicted). Images get uploaded as JPG, as before:

Hard to describe how much hugs I can give this, cause this logout bug is infuriating, looks like Apple are ACTUALLY reading my stuff.

I think for the interim we are just going to have to deal with the “double login” issue.

@j.jaffeux and I will have a think about this problem and see if we can use the new interface somehow, but I do not expect us to work on any hacks here for at least 2-3 months.