Lost session on Android. How to manage cookies

Hi all :slight_smile:

In my business application users can login to their accounts to access additional functions, and I have problem with keeping session on Android device. I read several topics about it, but most of them are from 2012r so maybe something changed in this problem.

From topics on this forum i learnt that on iOS device OS manage cookies and keeps session, on Android we have to care about it. I read also that i should save in my application filed [‘Set-Cookie’] from request and add to header in another request. But in my case it doesn’t work.

On iOS device second network.request as a result i receive true, unfortunately on Android is always false.

If someone could help me I would be very gratefull.  :slight_smile:

Here code: 

 local function networkListener( event ) if ( event.isError ) then print( "Network error!" ) else print ( "RESPONSE: " .. event.response ) end globals.printTable(event.responseHeaders) cookie = event.responseHeaders['Set-Cookie'] print(cookie) end local params = { username = Username, password = Password } local body = "username="..Username.."&password="..Password local params = {} params.headers = headers params.body = body network.request( "URL", "POST", networkListener, params )

I get true as a result from this request and I save cookie.

And here is code that is responsible for checking whether user is logged in.

I don’t know if it is important but first URL is only responsible for loggin, and second URL checks if user is still logged.

 local function networkListener( event ) if ( event.isError ) then print( "Network error!" ) else print ( "RESPONSE: " .. event.response ) end globals.printTable(event) end local headers = {} headers["Cookie"] = cookie local params = {} params.headers = headers network.request( "URL", "POST", networkListener, params )

I’m having the same problem. I hope that this problem will be resolved shortly.

I’m having the same problem. I hope that this problem will be resolved shortly.