问题
in my Nativescript Angular application, i authenticate to a node.js server using express-session and a nativescript webview. The server sends me back a cookie (connect.sid) containing the sessionid that i will use to access the node.js app.
I cannot read the connect.sid cookie in response from the server on iOS. I am currently using NSHTTPCookieStorage.sharedHTTPCookieStorage.cookies, and this contains a connect.sid, but its value is not the right one.
I managed to do that on Android using the following code:
var cookieManager = android.webkit.CookieManager.getInstance();
var cks = cookieManager.getCookie(myserverdomain);
I am trying to do the same on iOS:
const sharedCookieInstance: any =
NSHTTPCookieStorage.sharedHTTPCookieStorage;
const cookies: any = sharedCookieInstance.cookies();
but, as i wrote before, the connect.sid that i get from this on iOS is not the 'final' value.. (it seems to be the first connect.sid instantiated when you do a first request)
I've read half of the web without finding an answer. Can someone please help me ?
Thanks in advance
//Android, working
var cookieManager = android.webkit.CookieManager.getInstance();
var cks = cookieManager.getCookie(myserverdomain);
//iOS, not working
const sharedCookieInstance: any =
NSHTTPCookieStorage.sharedHTTPCookieStorage;
const cookies: any = sharedCookieInstance.cookies();
来源:https://stackoverflow.com/questions/54039460/nativescript-webview-get-cookies-on-ios