Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DefaultHttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost("http://caro-os.de/idesk/index.php");
- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
- nameValuePairs.add(new BasicNameValuePair("login_act", "niklas.riecken"));
- nameValuePairs.add(new BasicNameValuePair("login_pwd", "passwort"));
- try {
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- HttpResponse response = httpclient.execute(httppost);
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- Cookie cookie = null;
- List<Cookie> cookies = httpclient.getCookieStore().getCookies();
- for (int i = 0; i < cookies.size(); i++) {
- cookie = cookies.get(i);
- }
- Cookie sessionCookie = cookie;
- CookieSyncManager.createInstance(this);
- CookieManager cookieManager = CookieManager.getInstance();
- if (sessionCookie != null) {
- cookieManager.removeSessionCookie();
- String cookieString = sessionCookie.getName() + "=" + sessionCookie.getValue() + "; domain=" + sessionCookie.getDomain();
- cookieManager.setCookie("caro-os.de", cookieString);
- CookieSyncManager.getInstance().sync();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement