I have recently worked through a bunch of kinks making cross-domain ajax calls to a GAE app and it is working beautifully, however, I am trying to set an http session id when making said service call and开发者_如何转开发 it is working fine, except that every time I perform the request, the session is null again. I'm assuming that this is because an ajax call and not making the request over http? How can I go about this?
Session tracking is usually done with cookies. If you are using Cross-Origin Resource Sharing (http://www.w3.org/TR/access-control/), then cookies are not included in the request by default. In order to send cookies along with your request, add the following to your XmlHttpRequest:
var xhr = new XmlHttpRequest();
if ("withCredentials" in xhr) {
xhr.withCredentials = "true";
}
精彩评论