Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- HttpPost post = new HttpPost("http://www.derpforum.nl/?p=login");
- List<NameValuePair> parameters = new ArrayList<>();
- parameters.add(new BasicNameValuePair("username", "Kattoor4"));
- parameters.add(new BasicNameValuePair("password", "xxxx"));
- parameters.add(new BasicNameValuePair("ip-check", "on"));
- UrlEncodedFormEntity sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
- post.setEntity(sendentity);
- CookieStore cookieStore = new BasicCookieStore();
- HttpContext httpContext = new BasicHttpContext();
- HttpClient client = new DefaultHttpClient();
- httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
- HttpResponse response = client.execute(post, httpContext);
- System.out.println(response.getStatusLine());
- List<Cookie> cookies = cookieStore.getCookies();
- for (int i = 0; i < cookies.size(); i++) {
- System.out.println("Cookie " + i + " name: " + cookies.get(i).getName());
- System.out.println("Cookie " + i + " value: " + cookies.get(i).getValue());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment