Cookie in weview SDK 30

Navraj Singh 1 Reputation point
2022-02-24T01:28:39.637+00:00

In Xamarin Android SDK 30, when trying to set webview cookie does not work.

string cookieString = string.Format("{0}={1}; path=/;domain={2}; secure; ", Strings.SessionCookie, encryptedCookie, "value");

if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
CookieManager.Instance.SetAcceptThirdPartyCookies(webView, true);
}
else
{
CookieManager.Instance.SetAcceptCookie(true); //this function doesn't work from lollipop(API21) and above
}
CookieManager.Instance.SetCookie(RootCookieDomain, cookieString);

            webView.Settings.JavaScriptEnabled = true;
            webView.Settings.DomStorageEnabled = true;
            webView.LoadUrl(ConsentManagementLink);
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,354 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.