How do I add cookies to webview


Hi I have a website that I need to open in webview on my app and have it signed on using a cookie that I already have.
I could not find any code samples out there to add a cookie to web view for iOS & Android. Could anyone here point me in the right direction?


Did you find a solution for this?


I have not found anything yet


Without having looked much into it, I think you have to use the platforms CookiManager/Storage to set cookies.

On Android it should be as simple as this:

const cookieManager = android.webkit.CookieManager.getInstance();
cookieManager.setCookie(‘http://url/’, ‘id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT; Secure; HttpOnly’);

On iOS it looks more complicated, you can get the SharedCookieStorage like this:

const cookiesStorage = utils.ios.getter(NSHTTPCookieStorage, NSHTTPCookieStorage.sharedHTTPCookieStorage);

But I think I better just refer to this stackoverflow post on how to set the cookie in Swift: