npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cordova-plugin-android-cookieflush

v1.0.0

Published

Forces the Android WebView CookieManager to flush cookies to disk immediately, so cookies are not lost when the app process is killed.

Readme

cordova-plugin-android-cookieflush

A Cordova plugin that forces the Android WebView's CookieManager to flush cookies to disk immediately, so cookies (e.g. login/session cookies) are not lost when the app process is killed shortly after they are set or cleared.

Platform: Android only Minimum SDK: Android 5.0 (API 21) npm: https://www.npmjs.com/package/cordova-plugin-android-cookieflush


Why

Android's WebView (Chromium) batches cookie writes and only persists them to disk periodically (roughly every 30 seconds). If the app process is killed before that flush happens — for example when the user exits via the hardware back button, or the OS reclaims the process — any cookie written or deleted in that window is lost. On the next launch the WebView reads the stale cookie jar from disk, so a fresh login can appear logged out, or a logout can appear still logged in.

android.webkit.CookieManager.flush() forces the in-memory cookie jar to be written to disk. This plugin exposes that call to JavaScript and also runs it automatically when the app is paused or destroyed.


Installation

cordova plugin add cordova-plugin-android-cookieflush

What it does

Provides one method on cordova.plugins.cookieFlush:

| Method | Description | |--------|-------------| | flush(success, error) | Forces the WebView cookie jar to be written to disk. Both callbacks are optional. |

In addition, the plugin flushes automatically (no JS required) on the Android lifecycle events onPause and onDestroy, covering Home-button, task-switch, and swipe-away closes.


Usage

Call flush right before exiting the app, or after a login/logout, so the cookie change reaches disk before the process can be killed:

cordova.plugins.cookieFlush.flush(
    function () {
        // cookies persisted — safe to exit
        navigator.app.exitApp();
    },
    function (err) {
        console.error('Cookie flush failed:', err);
        navigator.app.exitApp();
    }
);

flush is safe to call fire-and-forget (both callbacks are optional):

cordova.plugins.cookieFlush.flush();

Notes

  • Android only. iOS WKWebView has no equivalent flush API; cookies there are persisted by WKWebsiteDataStore automatically. The plugin is not installed on other platforms, so a guarded call is a safe no-op.
  • The flush() JS call runs CookieManager.flush() on a background thread; the automatic onPause/onDestroy flushes run synchronously so they complete before the process is torn down.

License

ISC