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
jQuery.ajaxSetup({ xhrFields: { withCredentials: true } });
in the ready() function for pages where you have AJAX and things will suddenly go right for you…
Keith
Latest posts by Keith (see all)
- Privacy, PII, Europe and your business - May 19, 2017
- Website Security Scanning – CMS checks - April 2, 2017
- SEO Performance checking and monitoring - April 2, 2017
- Landing Page Monitoring - March 13, 2017
- 3 Ways In Which Google’s Mobile First Ranking Affects SEO - January 4, 2017