iOS Question how can I get the cookies in webview?

liulifeng77

Active Member
Licensed User
Longtime User
I try it like this, ,I can get the JSESSIONID,but can't get the sessionid.
Dim no As NativeObject = wb
log(no.RunMethod("stringByEvaluatingJavaScriptFromString:", Array("document.cookie"))

why??
 

Attachments

  • pi.PNG
    pi.PNG
    2.8 KB · Views: 285
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to get all the app cookies:
B4X:
Sub WebView1_PageFinished (Success As Boolean, Url As String)
   Dim no As NativeObject
   Dim cookies As List = no.Initialize("NSHTTPCookieStorage").RunMethod("sharedHTTPCookieStorage", Null).RunMethod("cookies", Null)
   For Each cookie As NativeObject In cookies
     Log($"Name: ${cookie.GetField("name")}, value: ${cookie.GetField("value")}"$)
   Next
End Sub
 
Upvote 0
Top