No Session Cookies on Internet Explorer 9 AJAX req

2019-02-12 04:29发布

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!

4条回答
【Aperson】
2楼-- · 2019-02-12 04:44

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.

查看更多
相关推荐>>
3楼-- · 2019-02-12 04:53

Just put Math.random() in url like,

$.ajax({
    type: "GET",
    url: "getRequestData.do?parameter=GetModelService&t="+Math.random(),
    data: "sub=ADD",
    cache: false,
    ................
    ...............
查看更多
做自己的国王
4楼-- · 2019-02-12 05:06

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

查看更多
SAY GOODBYE
5楼-- · 2019-02-12 05:07

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.

查看更多
登录 后发表回答