i am developing an app using phonegap for mobile platforms. For that im using js and so need to do many ajax calls. What i need to do is add a cookie (or modify its value if its already present) in the request header of an XMLHttpRequest.
I know it says here that its not possible - How do I SET a Cookie (header) with XMLHttpRequest in JavaScript?
But one seems to be able to modify the value of the 'Cookie' field in request headers, before making the xhr call, as its given in the answer here: http://developer.appcelerator.com/question/120728/set-cookies-using-setrequestheader--crashed-
It says that we can set the 'Cookie' field of the xhr req header for android and iphone in different ways like this:
if (Titanium.Platform.name == 'iPhone OS')
{
xhr.setRequestHeader("Cookie", "cookie1=value1");
xhr.setRequestHeader("Cookie", "cookie2=value2");
}
else
{
var cookieString = "cookie1=value1; cookie2=value2;";
xhr.setRequestHeader('Cookie', cookieString);
}
but im just using js, i cant use methods/classes for iphone/android. what i need to know is, if the browser sends a 'Cookie' header something like
xyz_cookie=vd0dKmD4mT; qwe=13aef60f7d0845
can i add another cookie "abc=1317331740;"
by using the xhr.setRequestHeader
method in a way that the browser sends all 3 cookies
xyz_cookie=vd0dKmD4mT; qwe=13aef60f7d0845 abc=1317331740;
in the cookie field in the request header of xhr?
If yes, pls tell me how?