I'm loading a website in Webview which uses some cookies to store session. I've written following lines to accept cookies
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().startSync();
CookieManager.getInstance().setAcceptCookie(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager.setAcceptFileSchemeCookies(true);
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
}
webView.loadUrl("https://www.irctc.co.in/nget/train-search");
At one stage (after payment from payment gateway), shouldOverrideUrlLoading method is called and after that it's supposed to land to transaction success page but it keeps going to login page. This is my method:
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
Log.d(TAG, "The URL is loaded in webview itself");
return false;
}
Using Chrome Developer Tools, I can see following cookies for website 
When I call method CookieManager.getInstance().getCookie(url) I can see that the cookies JESESSIONID and SLB_Cookie are present in webview, but not sure about that Local storage cookie. Also, if I remove the Local storage cookie in Chrome, I'm getting the exact same page (login page) instead of transaction success page like WebView. So I think if by any means if I check whether the Local Storage cookie is present in webview or not, and if not present then if I add it, my job would be done. But I'm not able to achieve either of the task.
from WebView not accepting some cookies
No comments:
Post a Comment