Search code examples
ajaxpostcookiessafarimobile-safari

Safari on iOS 11.4 not sending cookies on POST requests


I've been using the same code for years and things have been working very well on every browser so far:

$.ajax({
    url: '/test.php',
    data: parameters,
    dataType: 'html',
    type: 'post'
})

However, since my users started to upgrade to iOS 11.4, those who use the Private mode of Safari are having an issue with "being disconnected" from my website.

This is because ajax POST requests aren't sending any Cookies, apparently. A whole new session is created as part of that POST request (new cookies created, etc).

However, that doesn't affect anything on the GET requests themselves. They stay with the same cookies (and therefore same session), even though new cookies were set as part of the ajax POST request. It's like those ajax POST requests are "sandboxed", not affecting anything else.

Any ideas? Is this a bug on Safari on iOS 11.4 ?


Solution

  • We worked through a similar issue and figured out that it was actually related to Service Workers. From what I can tell, it's a bug in the latest version of Safari's implementation of Service Workers that causes some cookies not to be passed on POST in Private mode. For now, we have disabled our Service Worker and site functionality has returned to normal for those users.

    Not sure if this is your problem or not, but it sounds very similar. Hope this helps!