On Android, HTTPClient and Webview use different cookie stores. I need to authenticate with a POST using HTTPClient, grab my cookie, and then add to the System Cookie store that is used by webviews so I may use webviews going forward. I can find no example of how to do this anywhere on the web. Can anyone provide one that works? There is a somewhat reverse example here that just has not helped in actually extracting a cookie delivered by a site: https://jira.appcelerator.org/browse/TIMOB-15244
Here is code that doesn't work: I verified that everything works on iOS (which has a shared cookie store), and can see that my code properly logs in and attempts to load the page, but my site can't find the cookie so redirects to another login page. I'm open to any other methods to solve this problem... thanks
var xhr = Ti.Network.createHTTPClient(); xhr.open('POST', Ti.App.loginURL); xhr.onload = function () { var cookie = Titanium.Network.getHTTPCookiesForDomain(Ti.App.domain); Titanium.Network.addSystemCookie(cookie); webView.url = Ti.App.loggedInURL; }; xhr.send({ username:usernamevalue, password:passwordvalue });