Nativescript webview get cookies on iOS

不想你离开。 提交于 2020-05-31 05:03:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!