jQuery JSON cookie weirdness with HTTPS and Windows 10

Just a short post for those of you pulling your hair out on why the session cookie doesn’t appear to get passed along on your AJAX requests, especially concerning the latest browsers running on Windows 10.

I noticed this when the new Notes feature was working fine on my machines, yet my sons Windows 10 box kept getting the ajax requests failing. Thought it might be the squidGuard/Dansguardian he is behind fiddling with the request, but that wasn’t it – a quick ‘session’ adding some debug pointed out that the session cookie wasn’t being passed along for him, yet we were all on the same version of jQuery…. very weird!

Basically it’s because jQuery ‘forgets’ to pass along the credentials in this case, so you have to go and give it a kick to get it to do the right thing. Do the following

  xhrFields: {
    withCredentials: true

in the ready() function for pages where you have AJAX and things will suddenly go right for you…

The following two tabs change content below.


Director at Aykira Pty Ltd
Keith is a founder of Aykira & has over 18 years experience with everything Internet. From eCommerce to security, mobile to maps; large or small. PhD in Info Systems, member Australian & British Computer Society's, ex Yahoo. Architect/Engineer/Innovator.