Skip to content

Instantly share code, notes, and snippets.

@joshdholtz
Created January 22, 2013 21:40
Show Gist options
  • Save joshdholtz/4598699 to your computer and use it in GitHub Desktop.
Save joshdholtz/4598699 to your computer and use it in GitHub Desktop.
Stuff and things for cookies and things
/**
* @param cookie the cookie to set
*/
public String setCookie(HttpResponse response, Context context) {
for (int i = 0; i < response.getAllHeaders().length; ++i) {
Log.d(Constants.LOG, response.getAllHeaders()[i].getName() + " - " + response.getAllHeaders()[i].getValue());
}
Header[] cookies = response.getHeaders("Set-Cookie");
if (cookies.length > 0) {
Log.d(Constants.LOG, "ClientSession - found cookie = " + cookies[0].getValue());
this.setCookie(cookies[0].getValue(), context);
return cookies[0].getValue();
} else {
Log.d(Constants.LOG, "ClientSession - could not find cookie in response");
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment