Android Question HttpJob clear cookies

Bratt

Member
Licensed User
Longtime User
Dim jobLogin As HttpJob
jobLogin.Download(loginUrl)

I am a beginner in creating apps i am trying to create an app that parses a simple webpage

The login works fine but if i change user it logs in with the old user.

It seems like jobLogin stores cookies. Can this be the case and if so how can i clear them
 

Bratt

Member
Licensed User
Longtime User
Please oversee with my inexperience I have probably misunderstood something.

I actually did read that before posting but that post is referring to a HTTPRequest and not HTTPJob.
I thought that HTTPRequest was the old way and HTTPJob was the new way.
http://www.b4x.com/android/forum/threads/httputils2-web-services-are-now-even-simpler.18992/#content

Should i switch all my HTTPJob to HTTPRequest?

Or should i add this code to HttpUtils2Service. How can i access the code for HttpUtils2Service?
B4X:
Sub ClearCookies
  Dim r As Reflector
  r.Target = hc
  r.Target = r.GetField("client")
  r.Target = r.RunMethod("getCookieStore")
  r.RunMethod("clear")
End Sub
 
Upvote 0

Bratt

Member
Licensed User
Longtime User
Found the files i removed the library and added the files directly to my project instead

Added this to HttpUtils2service
B4X:
Public Sub ClearCookies(job As HttpJob) As Int
  Dim r As Reflector
  r.Target = hc
  r.Target = r.GetField("client")
  r.Target = r.RunMethod("getCookieStore")
  r.RunMethod("clear")
  Return 0
End Sub

and this to HttpJob
B4X:
'Clear cookies
Public Sub ClearCookies
    CallSubDelayed2(HttpUtils2Service, "ClearCookies", Me)
End Sub

Now my login seems to work :=)

But i don't know if i added it correctly. Should i use CallSubDelayed2 to call "ClearCookies" or is there a better way
 
Upvote 0
Top