14

Internet Explorer 9 is not sending session cookies with my AJAX requests.

When I issue an authentication request to my API via AJAX, it returns a response that sets a session cookie. Subsequent calls to the API via AJAX do not send the cookie back to the server.

The API is located on the same host. Similarly, regular non-AJAX page requests also do not show the session cookie. I turned off all privacy and security settings in Internet Options. Chrome sends the cookies properly.

How do I get IE to return the cookies? Thanks!

Not Specified
  • 191
  • 2
  • 7
  • Can you post the HTTP request and response headers? – slashingweapon Nov 12 '12 at 21:03
  • I encountered the same problem today. I havn't yet found a solution to it. Please keep this Question updated on possible approaches! – Cobra_Fast Nov 19 '12 at 16:05
  • I've found http://www.dotnet-developer.de/2012/01/aspnet/session-cookies-lost-in-internet-explorer-ie9/ but I havn't fully understood it yet. If I only add the described HTTP-Header everything seems to work but IE still says that I don't have a privacy policy. – Cobra_Fast Nov 22 '12 at 17:11
  • 1
    I think your question is already answered in another post: http://stackoverflow.com/a/389458/344477 – Zilvinas May 28 '13 at 12:10

4 Answers4

2

The URL I was attempting to access used an underscore character ('_'). This is an invalid URL and so Internet Explorer does not accept the cookies properly. Fixing this solved my instance of the problem.

Not Specified
  • 191
  • 2
  • 7
  • I have the same problem, and I also have underscores in URL. Did your URL have the underscore in the domain or sub-domain OR in the rest of the URL? – am-rails Dec 24 '13 at 16:20
0

I had this issue with IE9 for a get request. I converted from $.getJSON (using a url with query string parameters) to $.ajax (using a post). My theory would be that similar to MS's MVC server library, IE doesn't like get requests that return JSON.(you have to specifically allow this in MVC or it gives you an error indicating that get requests that return JSON have some security risk error) Anyway, since this was one of my top google hits, I figured I'd post what worked for me.

Zephryl
  • 343
  • 2
  • 9
0

Just put Math.random() in url like,

$.ajax({
    type: "GET",
    url: "getRequestData.do?parameter=GetModelService&t="+Math.random(),
    data: "sub=ADD",
    cache: false,
    ................
    ...............
leonhart
  • 1,193
  • 6
  • 12
0

try to avoid using localhost or 127.0.0.1 as part of your URL and see if it makes any difference.

demp
  • 12,665
  • 2
  • 23
  • 17