Android Question use JavaObject create NewCookie Will be added destructiveness quotation mark in the CookieValue for add cookies to HttpJob

yluff

New Member
Hi all,
use the code can add to the cookie : foo1="bar1"
but use Fiddler get the cookie is : foo1=bar1 ,there has no quotation mark, What do I need to do?
thaks!

Dim jo As JavaObject = HttpUtils2Service.hc
Dim client As JavaObject = jo.GetField("client")
Dim r As Reflector
r.Target = client.RunMethod("cookieJar", Null)
Dim CookieManager As JavaObject = r.GetField("cookieHandler")
Dim cookieStore As JavaObject= CookieManager.RunMethodJO("getCookieStore",Null)
Dim uri As JavaObject
uri.InitializeNewInstance("java.net.URI", Array("http://8.8.8.8"))

Dim NewCookie As JavaObject
NewCookie.InitializeNewInstance("java.net.HttpCookie",Array("foo1","bar1"))
cookieStore.RunMethod("add", Array(uri,NewCookie))
 

yluff

New Member
Please use [code]code here...[/code] tags when posting code.

B4X:
NewCookie.InitializeNewInstance("java.net.HttpCookie",Array("foo1",$""bar1""$))

Thank you, boss!
Still can't do it,use your codes,the result is like that
 
Upvote 0

yluff

New Member
It shouldn't matter. Can you post the Java code?

You're right!
Before you gave me ‘NewCookie.RunMethod("setVersion", Array(0))’, I tried NewCookie.RunMethod("setVersion", Array(0)) and NewCookie.RunMethod("setVersion", Array(1)) ,But none of them work,i Call the following code it work ,now I used your code, and he was surprised and normal.
thank you !

#If JAVA
import java.net.HttpCookie;
public HttpCookie createHttpCookie(String cname,String cvalue) {
HttpCookie cookie = new HttpCookie(cname, cvalue);
cookie.setVersion(0);
return cookie;
}
#End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…