php - Setting cookies in Android URL Connections -
i using code not setting cookie...
url url = new url("http://10.0.2.2/test2.php"); httpclient httpclient = new defaulthttpclient(); cookiestore cookiestore = new basiccookiestore(); cookie cookie = new basicclientcookie("xxt", "5a5b98563c4aabd675b81e4ba0fdf6cf"); cookiestore.addcookie(cookie); cookie cookie2 = new basicclientcookie("xxt", "5a5b98563c4aabd675b81e4ba0fdf6cf"); cookiestore.addcookie(cookie2); httpcontext localcontext = new basichttpcontext(); localcontext.setattribute(clientcontext.cookie_store, cookiestore); httppost post = new httppost("http://10.0.2.2/test2.php"); httpresponse response = httpclient.execute(post, localcontext); toreturn = entityutils.tostring(response.getentity()); //inputstream = conn.getinputstream(); //toreturn = inputstreamtostring(is).tostring(); log.d("downloaded", toreturn);
what doing wrong?
i'm doing this:
basicclientcookie cookie = new basicclientcookie("xxt", "5a5b98563c4aabd675b81e4ba0fdf6cf"); cookie.setexpirydate(new date("fri dec 11 15:24:17 gmt+06:00 2015")); cookie.setdomain("10.0.2.2"); cookie.setpath("/"); cookie.setversion(1); cookie.setcomment(""); cookie.setvalue("5a5b98563c4aabd675b81e4ba0fdf6cf"); cookiestore.addcookie(cookie);
Comments
Post a Comment