Skip to main content

cookies · set_cookies · clear_cookies

This tool on every surface: CLI · MCP · Python · JavaScript · Go · Java · .NET

Read, set or clear the current WebView's cookies — the ones its page's URL is sent, HttpOnly ones included, which document.cookie cannot see. These call app_cookies.

cookies​

def cookies() -> list[dict]

The current WebView's cookies: the ones its page's URL is sent, HttpOnly ones included. Needs a web context -- context() first.

Each is a dict with Vibium's keys: name, value, domain, path, expires (seconds since the epoch, absent for a session cookie), httpOnly, secure, sameSite.

set_cookies​

def set_cookies(cookies: list[dict]) -> None

Set each cookie on the current page and read the store back, so one the browser accepted and stored expired raises NotConfirmedError. Each needs name and value; the rest default to the page's host, / and a session cookie.

clear_cookies​

def clear_cookies(name: str | None=None) -> None

Delete the current page's cookies, or only those called name.

Examples​

Read the WebView's cookies​

for cookie in device.cookies():
print(cookie["name"], cookie["value"])

The same call from the command line, mobium cookies, printed on an Android 15 emulator:

no cookies for about:blank

mobium cookies on an Android 15 emulator

mobium cookies on an Android 15 emulator

device.clear_cookies("session")