Mobile Apps: Identity Session/Cookie Not Maintained

That seems to have fixed it! Again, I thank you so much!

You guys never sleep … amazing.

1 Like

If I implement this now on the newest Wappler version will it work? Also will the next Wappler update I do just override this?

@daves88
If you are having issues, check:

Yes I have.. I have gone through every forum topic trying every suggested solution but still nothing. Everytime I login the cookies are not stored. The only thing I haven’t tried is replacing the dmxappconmect file as per above.

  1. Are those http-only?
  2. On your login request do you have something else?:
  3. Have you tried calling a restricted API? (Don't forget credentials=true)

Yes I’m trying to hit an api action with security restrict and security identify at the start of the action. I have credentials ticked in server action . So when logging in I check safari dev logs while mobile connected to laptop and the cookies are empty. On web it’s working perfectly . So clearly authentication cookie not being stored on iOS

I can see origin is: capacitor://localhost
Is that on your cors settings?
Have you tried this on capacitor.config.json?

  "server": {
    "androidScheme": "https",
    "hostname": "domain.com"
  }
}

Where domain.com is your backend

Yes that’s in my cors, and yes changed the config file

Have you tested a new mobile project on capacitor to see if the login credentials work and if cookies are stored? On latest Wappler version ? I’m running nodejs as well

Will try a new one but without a Mac, so it has to be Android

Ok.. btw here is my capacitor.config.json (i have my actual name and domain but below I have just put xx instead.

{
"appId": "com.xxxxx.xxx",
"appName": "xxx",
"webDir": "www",
"bundledWebRuntime": true
"plugins": {
"CapacitorCookies": {
"enabled": true
},
"CapacitorHttp": {
"enabled": true
}
},
"server": {
"androidScheme": "https",
"iosScheme": "https",
"hostname": "app.mxxxx.com.au"
}
}

1 Like

I'm facing an error here, but hard to catch, let me do some more test please

1 Like

No problem. Honestly I don’t think this was ever resolved. The above patch released years ago is the only band aid solution I have found. And over the years who knows what could have changed with iOS updates that renders that patch useless now. Very frustrating that I’m stuck with an issue as simple as allowing a mobile app to login.

How is your login step?

Can you make a simple login (on ios) and then navigate with dmx.app.data on the console till you get to the api form?
I get an error like
lastError: message: "Response was not valid JSON"

I have no login error.. I can login fine: 1. lastError:

  1. message: ""
  2. response: null
  3. status: 0

Got it working in my case, I think the problem showed above comes on how response arrives..
I think it differs on apache/nginx but I'm not entirely sure:

Try this:
Delete the server thing on your capacitor.config.json and use https://localhost (add it for cors)
Disable http plugin

Server side:

Security provider:

config.json:

{
  "debug": true,
  "secret": "XXXXX",
  "port": 5000,
  "cors": {
    "origin": [
      "capacitor://",
      "capacitor://localhost",
      "http://localhost",
      "capacitor-electron://localhost",
      "http://localhost:61950",
      "https://localhost"
    ],
    "allowedHeaders": "accept,authorization,content-type,origin,referer"
  }
}

Client side:
capacitor.config.json:

{
  "appId": "com.example.app",
  "appName": "helloworld",
  "webDir": "www",
  "bundledWebRuntime": true,
  "plugins": {
    "CapacitorCookies": {
      "enabled": true
    },
    "CapacitorHttp": {
      "enabled": false
    }
  }
}

apiform:

<form is="dmx-api-form" id="apiform1" method="post" credentials="true" action="https://mydomain.com/api/test/mobilelogin">

PS: Don't forget to include credentials=true on api login form..

Thank you.. which capacitor.config.json are you referring to? ios/App/App/capacitor.config.json or ios/capacitor.confiog.json ?? also which config.json are you referring to? I dont have a config.json

on my server side config I have this: {
"debug": true,
"secret": "xxxxx",
"cors": {
"origin": [
"https://app.xxxxxxcom.au",
"capacitor://",
"capacitor://localhost",
"http://localhost",
"capacitor-electron://localhost",
"http://localhost:55727",
" http://127.0.0.1:55727"
],
"methods": "GET,POST,OPTIONS,PUT,PATCH,DELETE,CONNECT",
"allowedHeaders": "accept,authorization,content-type,origin,referer, x-requested-with"
},

You don't have a capacitor.config.json on root folder?
image

Edit that one, then when clicking build button, the bundler should make automatically another version for the iOS

Try adding https://localhost (with https)