title: React native web view keeping url even on clearing cache
body: <p>I'm working with react native web view where in we load a website maintaining session in web view using a token. When I login to the app and move the user to web vie two load the site as per user login, session is maintained by a url sent in api response and app loads well but when I logout i.e. navigate to login screen and log back in with a new user, the old user session is still maintained. How can we clear that? I have tried clearing cache, clearing url and assigning value again, but none works. Sharing my code for web view</p>
  <pre><code>const reload=()=&gt;{
  if (url !== route.params.url) {
    handleUrlChange(route.params.url)//Changing url for web view as per route from login
  }
   setLoading(true);}
  
  useFocusEffect(
  React.useCallback(() =&gt; {
    reload()
    return () =&gt; {
    };
  }, []));
  
  const clearLocalStorage = () =&gt; {
  handleCookieStorage(true), () =&gt; {
    setTimeout(() =&gt; {
      handleCookieStorage(false);
    }, 2000);
  };};
  
  const logoutUserClearInfo = () =&gt; {
  setURl(‘’)//Clearing url for web view while logging out
  clearLocalStorage()
  ClearCache.getAppCacheSize((value, unit) =&gt; {
    console.log(&quot;cache size&quot;, value, unit) // check size
    ClearCache.clearAppCache(data =&gt; {
      //alert(data) // will alert the new size
    });
  })
  AsyncStorage.getAllKeys()
      .then(keys =&gt; AsyncStorage.multiRemove(keys))
    navigation.canGoBack() ? (
      navigation.navigate('Authentication') 
   ) : navigation.navigate('Authentication') }
  
  const jsCode = `window.ReactNativeWebView.postMessage(document.documentElement.innerHTML);(function(){
  ${isCookieClear?`window.localStorage.clear(); window.sessionStorage.clear();`:''}})();`;
  
  
  &lt;WebView scalesPageToFit
      startInLoadingState = {true}
      ref = {webViewRef}
      originWhitelist={['*']}
      style={styles.container} source={{ uri: url  }} onLoadStart={() =&gt; (reload())} onLoadEnd={() =&gt; (setLoading(false))}
      javaScriptEnabled={true}
      domStorageEnabled={true}
      setSupportMultipleWindows={false}
      automaticallyAdjustContentInsets={false}
      allowsFullscreenVideo={true}
      injectedJavaScript={jsCode}
      thirdPartyCookiesEnabled = {false}
      onMessage={event =&gt; {
         if (event.nativeEvent.data === 'stoprefresh'){
            handleStopRefresh(true)
            console.log('STOP REFRESH', stopRefresh)
          }
      }}
      onScroll = {onScroll}
      incognito = {true}
      allowsLinkPreview = {false}
      allowUniversalAccessFromFileURLs={true}
      onShouldStartLoadWithRequest={(event) =&gt; {
        if (!event || !event.url) {
          return true;
        }
          if (event.url.includes('Logout')) {
            webViewRef.current.stopLoading();
            setLoading(false);
            Alert.alert(
              &quot;AppName&quot;,
              &quot;Are you sure you want to logout?&quot;,
              [
                {
                  text: &quot;No&quot;,
                  onPress: () =&gt; console.log(&quot;Cancel Pressed&quot;),
                  style: &quot;cancel&quot;
                },
                { text: &quot;Yes&quot;, onPress: () =&gt; { logoutUserClearInfo() }
                }
              ]
            );
            return false
           }            
           else {
            return true
          }
        }}
      /&gt;
  </code></pre>