开发者

Cross-Domain Ajax Calls and maintaining session on Google App Engine

开发者 https://www.devze.com 2023-02-21 18:32 出处:网络
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

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";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消