Clearing cookies in SFSafariViewController?

I am using SFSafariViewController to authenticate against a website (SAML idP) and retaining my session using a cookie. I opted to use SFSafariViewController because my users could log in to the site using Safari or another app's instance of SFVC to achieve single sign on because as I understand it, the cookie store between native Safari and instances of SFSafariViewController are more or less shared.

However, clearing the cookies in Safari settings in the settings app doesn't clear the cookies in my app's instance of SFVC. I have also tried logging out of the site in Safari but the cookie / session is still retained in my app's instance of SFVC.

Is this expected behavior from SFVC?

Thanks,

Lucas

Anyone from Apple have any thoughts on this? Trying to understand if I should put in a bug for this or not. Thanks!

I've noticed that. In additional, in my tests, it seems like session cookies are NOT shared between Safari and SFSafariViewController, but only the presisted cookies (those with a future expiration date). Like you, I wonder if this is by design or a bug. Or perhaps something I'm missing. I've tested this with iOS 9.3.2 on an iPhone 6 as well as 9.2 on the simulator. I've noticed this while testing using SAML (where our IdP uses session cookies) and then confirmed it with a simple test page that sets both session and persisted cookies. When switching between Safari and the App with a SFSafariViewController, only the persisted cookie is shared.


So it seems there's separate session cookies between Safari and SFSafariViewController. I can't find any references confirming this. The standard Apple docs just says "cookies and other website data" are shared while some others report cookies are not consistently shared. Neither distinguish which type of cookies. Anyone have insight on this?

Bumping this thread as I am also interested and don't see a solution.
// remove session data
      let dataTypes = Set([WKWebsiteDataTypeCookies,
                 WKWebsiteDataTypeLocalStorage, WKWebsiteDataTypeSessionStorage,
                 WKWebsiteDataTypeWebSQLDatabases, WKWebsiteDataTypeIndexedDBDatabases])
      WKWebsiteDataStore.default().removeData(ofTypes: dataTypes, modifiedSince: Date.distantPast, completionHandler: {
        let vc = SFSafariViewController(url: targetURL)
        self.safariViewController = vc
        vc.delegate = self
        target.present(vc, animated: true)
      })
It may help to clear session data

Thanks a lot it's is working for me.

Clearing cookies in SFSafariViewController?
 
 
Q