Set COOKIES using setRequestHeader() = CRASHED ?
Hello,
I seem to get problems as soon as I have more than one cookie sending through setRequestHeader("Cookie","?????");
Here's my code
var cookieString = "cookie1=value1; cookie2=value2;";
xhr = Ti.Network.createHTTPClient();
xhr.open(method, url);
xhr.setRequestHeader('Cookie', cookieString);
xhr.send();
If I remove the second variable (cookie2=value2) from the cookieString, guess what.. it works !!
As soon as I add it back, it fails.
This seems to be the correct format for cookies in HTTP headers.
Anyone else noticing this with multiple cookie variables?
To sum up,
This code works.
xhr.setRequestHeader("Cookie", "cookie1=value1");
But when it comes to multiple variables, it fails.
xhr.setRequestHeader("Cookie", "cookie1=value1; cookie2=value2");
P.S. I also look at "titanium_mobile/iphone/Classes/TiNetworkHTTPClientProxy.m" seems the problem is here in "-(void)setRequestHeader:(id)args" method.
suggestions, guides, hints or solutions would be really appreciated.
Regards,
Neti.
1 Answer
-
Accepted Answer
I would suggest that you create a loop to add the cookies to the request header.
The code you referenced shows that when the key is "cookie" it is only expecting one cookie at a time… further down in the code, it appears that it appends the cooke to the cookies object