X xor83 Member Licensed User Longtime User Jan 13, 2016 #1 Hello, I am creating an app where I have to save login details/session for which I have to save cookies which I received from server, I am using HttpJob library and everything is working fine until I restart the app. How should I save details contained in HttpJob object? So that I don't have to ask user to login again. I need to save HttpJob object state may be serialize somewhere? Can anyone help me on this?
Hello, I am creating an app where I have to save login details/session for which I have to save cookies which I received from server, I am using HttpJob library and everything is working fine until I restart the app. How should I save details contained in HttpJob object? So that I don't have to ask user to login again. I need to save HttpJob object state may be serialize somewhere? Can anyone help me on this?
Erel B4X founder Staff member Licensed User Longtime User Jan 14, 2016 #2 You can get the response headers in hc_ResponseSuccess and set them as the job Tag property: Code: Copy Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int) Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _ True, TaskId) Dim job As HttpJob = TaskIdToJob.Get(TaskId) job.Tag = Response.GetHeaders End Sub Now you can check whether there is a Set-Cookie header and get the cookies from this header. Upvote 0
You can get the response headers in hc_ResponseSuccess and set them as the job Tag property: Code: Copy Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int) Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _ True, TaskId) Dim job As HttpJob = TaskIdToJob.Get(TaskId) job.Tag = Response.GetHeaders End Sub Now you can check whether there is a Set-Cookie header and get the cookies from this header.
X xor83 Member Licensed User Longtime User Jan 14, 2016 #3 Thanks Erel for the reply. What should I pass in this section? Code: Copy Sub JobDone(JobRes As HttpJob) Select JobRes.JobName Case "AppLogin" AppLogin_ResponseSuccess(job,JobRes.JobName) ' << ResponseSuccess ? End Select JobRes.Release End Sub Last edited: Jan 15, 2016 Upvote 0
Thanks Erel for the reply. What should I pass in this section? Code: Copy Sub JobDone(JobRes As HttpJob) Select JobRes.JobName Case "AppLogin" AppLogin_ResponseSuccess(job,JobRes.JobName) ' << ResponseSuccess ? End Select JobRes.Release End Sub
Erel B4X founder Staff member Licensed User Longtime User Jan 15, 2016 #4 Please use [code]code here...[/code] tags when posting code. Use HttpUtils2 source code instead of the library and replace the existing hc_ResponseSuccess with the one I posted. Later you can get the map of headers with: Code: Copy Sub JobDone(j As HttpJob) ... Dim headers As Map = j.Tag Upvote 0
Please use [code]code here...[/code] tags when posting code. Use HttpUtils2 source code instead of the library and replace the existing hc_ResponseSuccess with the one I posted. Later you can get the map of headers with: Code: Copy Sub JobDone(j As HttpJob) ... Dim headers As Map = j.Tag