Cookies + ionic + cordova... does this work?

I’m trying to implement an auth client talking to a server that REQUIRES the use of cookies, I have no control over the server side and MUST use cookies.

I have tried playing with the standard 1.3 angular $cookies, I’ve tried playing with ipCookies and I can’t get the very bare basic cookie example to work when on the device itself.

I’m testing this on android 5.0.2 and I’m using the chrome remote debugger to try and see what’s going on.

It seems that no matter what I do I just cannot set a cookie as following the simplest examples always returns undefined

Does anyone have a basic example of simply setting and getting a cookie in angular that works inside cordova, on device?

My last resort is to try and revert to using jquery, which, although I have a perfectly good piece of working jquery code, I really really don’t want to do, I want to use pure angular.

I also notice that adding the bower component using ionic add angular-cookies doesn’t seem to work, I had to install it manually??? Strangely ionic add angular-cookie, (i.e. the ipCookies plugin) does work though.

Given up on angular cookies, they just don’t work.

I’m now trying to revert to a previous jquery piece of code (which means I’ve had to include jquery with angular * shudder *)


The code “still” doesn’t work, despite working in my pure jquery code base. So I’m guessing there’s something environmental to ionic builds that is messing with the ability to set cookies… and no, it doesn’t appear to be a whitelist plugin problem, I can query url’s fine, just not set a cookie.

(EDIT: re: the above, confirmed, I just upgraded my old cordova/jquery code and it works perfectly with cordova 5.0.0, cordova android platform 4.0.0 and the whitelist plugin. “Something” is strange with ionic and cookies…)

It looks like jquery’s $.cookie() …just …doesn’t …work under ionic?

I’d be interested to see some code revolving around setting a cookie that actually sodding works.

Yep, very much given up with this for now, it seems the better approach is to write server side code to set cookie you pass as a parameter… which can’t be a good way of doing it! (and not ultimately what I’m doing)

The jquery cookies stuff just doesn’t work with ionic for some reason… although it “does” work in a pure jquery environment??? So it’s not cordova or the android web view.

My approach now is to just login every time it’s required and let the server side auth code set cookies (ie not my own code), if your session is null and the app still thinks it’s logged in then I just detect this and “relogin”.

I’m struggling with PouchDB / CoudhDB cookies authentication.
Thanks for the confirmation that it doesn’t work…