Cookie not saving in Web view in Xamarin(Android) -


i creating android application in xamarin. using web view display website. after user login website create cookie , should store in web view. there 2 web view in app, 1 web view displaying pages , if there text box in page page opened in second web view.

so when user tries login, second web view opened(as login page contains text box), after user enter details , click next button, second view closed , next page opened in first web view. after login cookie created , stored in web view , when user open app next time doesn't asks login. should happen.

the problem is, if user enter details , after clicks next button(next page loading in first web view) , quits application start app again cookies not exists , app asks login again.

after login reading cookie value on page finish event of webview , displaying in toast. if quits app after login, gets cookie value in toast when starts app again cookie doesn't exists anymore , asks me login again

public override void onpagefinished (webview view, string url)         {             try              {                 if (view.url == urls.url_index)                  {                     var cookiemanager = cookiemanager.instance;                     if (cookiemanager != null)                      {                         //getcookie string url                         string cookie = cookiemanager.getcookie (view.url);                         if (!string.isnullorempty (cookie))                          {                             string[] cookies = cookie.split (';');                             foreach (var newcookie in cookies)                              {                                 if (newcookie.trim().startswith (constants.cookie_name))                                  {                                     string cookievalue = newcookie.substring (newcookie.indexof ('='));                                                  toast.maketext(activity,cookievalue,toastlength.short).show();                                 }                             }                         }                     }                  }             }             catch (exception ex)              {                 console.writeline ("exception in storing cookie in home activity : "+ex.message);                 toast.maketext (activity, "exception : " + ex.message,toastlength.long).show();             }         } 

i don't know why happening, please help.

the cookies stored in ram best performance , synced every 5 minutes permanent storage. you'll need manually force cookiesyncmanager sync cookies in onpagefinished method they're still available when start application again. refer cookiesyncmanager documentation more details.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -