I solved this problem:
public void syncSession(final Context ctx){
new Thread(new Runnable(){
public void run(){
ProductManager pm = ProductManager.getInstance();
HttpPost httpget = new HttpPost(UrlConstants.SERVICE_URL_SYNC);
HttpResponse response;
String result = null;
try {
response = httpclient.execute(httpget);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
List<Cookie> cookies = httpclient.getCookieStore().getCookies();
if (! cookies.isEmpty()){
CookieSyncManager.createInstance(ctx);
CookieManager cookieManager = CookieManager.getInstance();
for (Cookie cookie : cookies){
Cookie sessionInfo = cookie;
String cookieString = sessionInfo.getName() + "=" + sessionInfo.getValue() + "; domain=" + sessionInfo.getDomain();
cookieManager.setCookie(UrlConstants.SERVICE_PRE_URL, cookieString);
CookieSyncManager.getInstance().sync();
}
}
}
}).start();
}
source
share