How Can I Use Cookies Without Eject?

Not sure if this help, but I recently found a way to manipulate the cookies without ejecting.
But the implementation is quite hacky:

  1. Create a WebView
  2. Inject javascript to change document.cookie
  3. Send message to notify that manipulation was done

The sample code for clearing cookie:

<WebView
    source={{ uri: "Your source" }}
    onMessage={(e) => {
        // Complete handler
    }}
    injectedJavaScript={`
        document.cookie
             .split(";")
             .forEach(function(c) {
                 document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";domain=your domain");
             });
             
             window.postMessage();
    `}
/>
4 Likes