I get HttpResponse from the server, checking for the correct username or password. When I load the url in webview , I want the webview have a cookie (the answer I get with postData() stored in webview . I want the webView to load a cookie and load the url with this cookie stored in web browsing.
I get an answer.
public HttpResponse postData() { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("https://example.com/login.aspx"); try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("txtUsername", "user")); nameValuePairs.add(new BasicNameValuePair("txtPassword", "123")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); String responseAsText = EntityUtils.toString(response.getEntity()); Log.v(TAG , "Response from req: " + responseAsText); return responseAsText; } catch (ClientProtocolException e) { } catch (IOException e) { } return null; }
And I load Url:
webView.loadUrl("http://a_page.com/getpage.aspx?p=home");
I think that I do not control the cookie, and I have no idea how to do this. Any suggestions or solutions?
Joakim Engstrom Apr 19 '11 at 13:13 2011-04-19 13:13
source share