Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 458
citizen conn Avatar asked Dec 07 '25 02:12

citizen conn


1 Answers

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";
}
like image 104
monsur Avatar answered Dec 09 '25 17:12

monsur