Android Question Restore session cookie after App restart

katzenkacke

New Member
Licensed User
Hello to the B4A-Community!
I'm new to B4A and really love the tool, as it allows me to develop the Android App that I ever wanted to create, without using Java.

I already developed a whole login process (OKHttpUtils2 sending SSL-encrypted request, parsing JSON result which also contains session cookie data besides the cookie that is set on successful login). I transfer the cookie in the JSON result again, so I don't need to parse HTTP response headers for finding my session cookie. I already figure out, that OkHttpUtils automatically stores cookies for further requests - perfect! But what if my App or the whole android system restarts completely? When the App is ended gracefully it stores the current session cookie in a configuration file an reloads it on next start.

So far my explanation, now the problem:
On App restart I reload the session cookie (which still may be valid) and I need to send it together with the first OkHttpUtils request, otherwise my WebService will assign a new cookie, which would require my App to log in again. On this helpful board I found the following line of code:

B4X:
csJob.GetRequest.SetHeader("Cookie", "Cookie data")

(csJob is my "check session HttpJob") But on compilation I get the following error:

Error description: Unknown type: anywheresoftware.b4h.okhttp.OkHttpClientWrapper.OkHttpRequest
Are you missing a library reference?
Occurred on line: 130
csJob.GetRequest.SetHeader("Cookie", "Cookie data")

So how can I send my cookie manually on Http-Requests?

Looking forward to your responses, thanks in advance!
 
Top