http-request icon indicating copy to clipboard operation
http-request copied to clipboard

How to automate login a website

Open EmyrsIro opened this issue 10 years ago • 3 comments

can someone guide me how i can automate login to a website using this library . in order to login cookies must be handled i have tried that .

HttpRequest request = HttpRequest.get("http://website.com/"); request.trustAllCerts(); request.trustAllHosts(); request.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1"); request.useCaches(true); String cookies = request.header("Set-Cookie"); String response = request.body(); StringBuilder sb = new StringBuilder(); sb.append("email=clientemail%40gmail.com&password=clientpass&login_button=Login"); HttpRequest rq = HttpRequest.post("http://website.com/").send(sb); rq.header("Cookie", cookies); String html = rq.body();

EmyrsIro avatar Jan 23 '16 17:01 EmyrsIro

:+1: I think there isn't this feature. It's would be a good improvement

joasgarcia avatar Apr 08 '16 17:04 joasgarcia

Maybe this helps https://developer.android.com/reference/android/accounts/AccountManager.html

nesjett avatar Oct 25 '16 18:10 nesjett

you may store session() it will keep user login until session ends

if(!isset($_SESSION['x'])) { header("Location: index.php"); } like this

sagar117 avatar Aug 10 '17 18:08 sagar117