Question

Android 4.4.2
Cordova 3.4.1
jQuery 2.1.0
jQuery Mobile 1.4.2

I need to post my login credentials to a server (IBM Domino 9.01 in this case, but it's irrelevant) and the server responds with a session cookie, among other things.

This works great on iOS, but I don't get any cookies what so ever using my Cordova/Phonegap app on Android. I see this using Chrome Dev Tools. I know that Android gets the cookie because I'm logged in and can browse around. But it doesn't seem to trickle down to the WebView where my JavaScript code lives.

I have modified my appName.java file:

import android.os.Bundle;
import android.webkit.CookieManager;
import org.apache.cordova.*;
public class Rooms extends CordovaActivity 
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xml

        CookieManager.setAcceptFileSchemeCookies(true); //available in android level 12
        CookieManager.getInstance().setAcceptCookie(true); //available in android level 12
        super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html");
    }
}

I'm not 100% sure about this part:

CookieManager.getInstance().setAcceptCookie(true)

It compiles and runs fine, but I can't access any cookies.

I need access to the cookies because, to my knowledge, there's no other way to extract the NONCE value in a session on a IBM Domino server.

Was it helpful?

Solution

I don't think this works I tried it on my phonegap android application . The Best solution is to use localStorage or sessionStorage. Maybe you can try to use some other means of sending sessions like using tokens or sending them through headers... that's what i'm doing now.. also check this out

Handling cookies in PhoneGap/Cordova

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top