aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes send sessionid cookie while making the AJAX request call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "send sessionid cookie while making the AJAX request call" Watch "send sessionid cookie while making the AJAX request call" New topic
Author

send sessionid cookie while making the AJAX request call

sen rajj
Greenhorn

Joined: Jun 08, 2006
Posts: 3
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jan 10, 2002
Posts: 61227
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sen rajj
Greenhorn

Joined: Jun 08, 2006
Posts: 3
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Ajax can not be used to talk to a second domain. Same Origin Policy [unless the browser supports CORS].

Eric
sen rajj
Greenhorn

Joined: Jun 08, 2006
Posts: 3
Thanks Eric for the response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: send sessionid cookie while making the AJAX request call