[英]How to disable autologin in a website - (Android Studio)
i'm writing an app but i've a problem, I make the GET and POST request with Jsoup to do the login in the Iliad website, when I run the app, it log in also with wrong credentials, I think it is because the website do the autologin, but i've no idea how to remove it.我正在编写一个应用程序,但我遇到了一个问题,我使用 Jsoup 发出 GET 和 POST 请求以在 Iliad 网站中进行登录,当我运行该应用程序时,它也使用错误的凭据登录,我认为这是因为该网站进行自动登录,但我不知道如何删除它。
This is the code:这是代码:
try {
res = Jsoup.connect("https://www.iliad.it/account/")
.method(Connection.Method.GET)
.header("Content-Type", "application/x-www-form-urlencoded")
.ignoreHttpErrors(true)
//.cookie("auth_mobile", "0")
.execute();
SESSID = res.cookie("ACCOUNT_SESSID");
//AUTH = res.cookie("auth_mobile");
response = Jsoup.connect("https://www.iliad.it/account/")
.method(Connection.Method.POST)
.header("Content-Type", "application/x-www-form-urlencoded")
.data("login-ident", MainActivity.id)
.data("login-pwd", MainActivity.pwd)
.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0")
.ignoreHttpErrors(true)
.followRedirects(true)
.cookie("ACCOUNT_SESSID", SESSID)
//.cookie("auth_mobile", "0")
.execute();
Errore = false;
doc = Jsoup.parse(response.parse().outerHtml());
System.out.println(doc);
} catch (Exception e) {...
Try getting the session cookie from the headers on the initial GET request:尝试从初始 GET 请求的标头中获取会话 cookie:
set-cookie: ACCOUNT_SESSID=9p3lg...1j2e3; path=/account/; HttpOnly
In any subsequent requests to the server you must set this as:在对服务器的任何后续请求中,您必须将其设置为:
Cookie: ACCOUNT_SESSID=9p3lg...1j2e3
So you should have something more like:所以你应该有更多的东西:
response = Jsoup.connect("https://www.iliad.it/account/")
.method(Connection.Method.POST)
.data("login-ident", MainActivity.id)
.data("login-pwd", MainActivity.pwd)
...
.cookie("Cookie", "ACCOUNT_SESSID=" + SESSID) // <<<
//.cookie("auth_mobile", "0")
.execute();
This should get you a step closer.这应该让你更近一步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.