'Android WebView - reset HTTP session

I'm using a WebView in an 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.



Solution 1:[1]

import android.webkit.CookieManager;

CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeSessionCookie();

removeSessionCookie() allows to keep other cookies but clear sessions.

Solution 2:[2]

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();

Solution 3:[3]

This worked for me:

WebStorage.getInstance().deleteAllData()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rumit Patel
Solution 2 Scoobler
Solution 3 grrigore