WebView Login Info

Hi, All.

I am trying to get my login information after logging into the site using WebView.

But when I use Request to access the URL address, the server shows that I am not using my login information (my cookie), and when I look at the request, I see that my login information is indeed not being used. How do I change this? Will using Request after logging in with WebView automatically take my cookie with it? :thinking:

You need to extract the cookies from the WebView and add them to your request manually. You can extract them from the WebView via document.cookie

Thanks for your reply, when I use document.cookie only some cookies are displayed and I found that the cookie status I want to use is “HTTP Only”. I don’t know how to fix it.

You could try to send the request with the WebView via .loadRequest(request). Maybe there it will add all cookies automatically. If this still doesn’t work, then send it from within the homepage via fetch() inside .evaluateJavaScript(script). If this also fails, then I’m out of ideas.

Thanks! Using evaluateJavaScript may work, but I encountered an error “JavaScript execution returned a result of an unsupported type” I used the async method. :joy:

You have to make sure that the last line of your injected javascript only returns simple types like string, number or boolean. The value of the last line will be returned from .evaluateJavaScript() and if Scriptable cannot convert it easily to string then it will complain. This will apparently also happen when you use async mode with .evaluateJavaScript()