Skip to content Skip to sidebar Skip to footer

Cookie Corruption With Multiple Createhttpclient Titanium Calls

While creating an Android app in Appcelerator's Titanium that involves both webView and background calls, I ran into a problem / bug where the cookies were getting corrupted on mul

Solution 1:

The HTTPClient documentation says "object is intended to be used for a single request," so I assumed everything would reset after multiple calls. But something was different after the first call.

Adding loader.clearCookies(base_url); to the code before setting the cookies seems to fix the issue.

var loader = Titanium.Network.createHTTPClient();  
loader.open("GET",base_url + url); 
loader.onload = function() {
    // process response
}
loader.clearCookies(base_url); // THE FIX.
loader.setRequestHeader('Cookie',Titanium.App.Properties.getString("cookies"));
loader.send(); 

Post a Comment for "Cookie Corruption With Multiple Createhttpclient Titanium Calls"