iOS11: Cookies intermittently blocked

Since introduction of iOS 11 I am having problems with cookies that seems to be intermittently blocked at startup of the webapp. First thing that happens when starting the webapp is that the user has to login. Login results in a cookie being added by the webservice. Next time the user starts the webapp the user is authenticated with information in the cookie and content is presented to the user. Sometimes this works fine but often the cookie with authentication information is not present in the request. If I then go to Settings, Safari and under section Privacy & Security change any of the settings, e.g "Ask Websites not to track me", the cookie will be present in the request first time I start the web app.


There doesn't seem to be any problem with missing cookies once your loged in. It's only when starting the webapp. Anyone with the same problem?

Accepted Reply

We were also having similar issue but found workaround for it.


In iOS 11, cookies are not shared between Safari and each web apps, but it seems a web app sometimes uses cookies that are cached in Safari side when sends a request. We guess this behavior (probably a bug) causes session invalid.


We have been calling web api using Fetch, when using it with a "cache: no-store" option, the behavior was fixed:


fetch('/path/to/auth', {
    credentials: 'same-origin',
    cache: 'no-store'
});


At least this workaround is working fine for our case.

Replies

can you help me please, i can't get cookie with session id from wkwebview in swift 4.1.