No Session Cookies on Internet Explorer 9 AJAX requests

左心房为你撑大大i 提交于 2019-11-30 01:16:38

问题


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!


回答1:


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.




回答2:


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.




回答3:


Just put Math.random() in url like,

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



回答4:


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



来源:https://stackoverflow.com/questions/13350652/no-session-cookies-on-internet-explorer-9-ajax-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!