• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

send sessionid cookie while making the AJAX request call

 
sen rajj
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

i am looking for a way to send sessionid cookie while making the AJAX request call.

i have tried with

try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}

ajaxRequest.setRequestHeader('Cookie', 'JSESSIONID=ASDSJDJSHDJHJSHDJHSJDHJHSD');

but it is not working. can someone help me to figure out?

Thanks in advance
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it is in the cookie to begin with, there is nothing you need to do, the Ajax Request will send it up.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting to the forums.

Just sending a made-up session id isn't going to do anything useful. As Eric pointed out, the browser will take care of sending the session cookie. Just let it do its thing.
 
sen rajj
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric and Bear thanks for the response.

Actually I am doing a single sign in two different domains, after successful logged in, whenever mobile browser communicating with one domain, we have to send the background request (AJAX call) with cookie to other domain to keep the session alive. In case of form submission browser able to manage the cookies for the domain and send in request. However AJAX call fails to send the cookies.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajax can not be used to talk to a second domain. Same Origin Policy [unless the browser supports CORS].

Eric
 
sen rajj
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric for the response.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic