Android WebView - reset HTTP session
I'm using a WebView in a开发者_StackOverflow中文版n Android app. I periodically to be able to reset the WebView http session so that the server app it is accessing will initialise a new session. I can't find how to do this - is this possible ?
Rgds, Kevin.
I think the clear cookie can make session close. More about session
CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
import android.webkit.CookieManager;
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeSessionCookie();
removeSessionCookie()
allows to keep other cookies but clear sessions.
There are a couple of things you can do to clear the webview depending exactly what you want to do:
webView.clearCache(true);
webView.clearHistory();
webView.destroy();
This worked for me:
WebStorage.getInstance().deleteAllData()
精彩评论