So this is currently how my app is set up:
1.) Login Activity. 2.) Once logged in, other activities may be fired up that use PHP scripts that require the cookies sen
The issue that you are facing seems to be by design for privacy/security purpose. In general any resource is not allowed to set a cookie it will not be able to receive. Here you are trying to set the cookie with the path trackallthethings from the resource /mobile-api/login.php which obviously is not working.
Here you have following two options
'/') ORHope this helps.
Since the API of HttpClient seems to change very fast, here is some working example code for HttpClient 4.5.1 to allow all (malformed) cookies:
class EasyCookieSpec extends DefaultCookieSpec {
@Override
public void validate(Cookie arg0, CookieOrigin arg1) throws MalformedCookieException {
//allow all cookies
}
}
class EasySpecProvider implements CookieSpecProvider {
@Override
public CookieSpec create(HttpContext context) {
return new EasyCookieSpec();
}
}
Registry<CookieSpecProvider> r = RegistryBuilder.<CookieSpecProvider>create()
.register("easy", new EasySpecProvider())
.build();
CookieStore cookieStore = new BasicCookieStore();
RequestConfig requestConfig = RequestConfig.custom()
.setCookieSpec("easy")
.build();
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCookieStore(cookieStore)
.setDefaultCookieSpecRegistry(r)
.setDefaultRequestConfig(requestConfig)
.build();