3

I want to send some data to a server through POST method in android. I am using the following code

DefaultHttpClient hc=new DefaultHttpClient();  
ResponseHandler <String> res=new BasicResponseHandler();  
HttpPost postMethod=new HttpPost(url); 
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); 
nameValuePairs.add(new BasicNameValuePair("name", "value"));     
nameValuePairs.add(new BasicNameValuePair("password", "value"));    
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));    
String response=hc.execute(postMethod,res); 

But I am getting the error response in my response xml. The error message is cookies are disabled in client machine. How do I need to enable cookies in android ?

THelper
  • 15,333
  • 6
  • 64
  • 104
Senthil
  • 513
  • 2
  • 13
  • 24

1 Answers1

1

You need to handle cookies with your request. See this and this related questions.

Community
  • 1
  • 1
kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
  • Hello friend, I am getting cookies size is 0 when i print the cookie using the getCookie method of CookieStore object. May I know where to find the cookie values and how to set those values while sending the request. Even if I use the sample given there, I am getting the same response "cookies are disabled in client machine" in my response xml body. – Senthil Nov 01 '10 at 11:29