Q: android cookies issue in application hy
i am developing an application that has to connect to a webserver and download and read json format data. i am able to login in it, but whenever i try to fetch other data, it returns failure.
i tried the same thing on browser by copy-pasting the urls using get method and it works. the application uses cookies to store the data.
how can i store cookies in an android application & send them to server?

A: Just check android development reference: http://developer.android.com/reference/java/net/HttpURLConnection.html
There is "Sessions with Cookies" paragraph ;-)

A: In your connecting thread,
set the cookie in your request header like this (sCookie is my static cookie String variable):
HttpURLConnection conn = (HttpURLConnection) url.openConnection();  
//.....
if(sCookie!=null && sCookie.length()>0){
    conn.setRequestProperty("Cookie", sCookie);
}

Below that, after receiving a response, get the cookie like this:
String cookie = conn.getHeaderField("set-cookie");
if(cookie!=null && cookie.length()>0){
    sCookie = cookie;
}

