Skip to main content

storage · set_storage · clear_storage

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

Save, restore or clear the current WebView's storage state: its cookies and its origin's localStorage and sessionStorage, in the shape Vibium saves — {cookies, origins: [{origin, localStorage, sessionStorage}]} — so a state saved by one restores in the other. These call app_storage.

storage​

def storage() -> dict

The current page's storage state, in the shape Vibium saves: {"cookies": [...], "origins": [{"origin", "localStorage", "sessionStorage"}]}.

set_storage​

def set_storage(state: dict) -> None

Restore a saved state: its cookies, and each origin's storage into the page only if the page is on that origin.

clear_storage​

def clear_storage() -> None

Empty the current page's cookies, localStorage and sessionStorage.

Examples​

Save the WebView's cookies and web storage​

import json

with open("state.json", "w") as f:
json.dump(device.storage(), f)

The same call from the command line, mobium storage -o state.json, printed on an Android 15 emulator:

saved state.json

mobium storage -o state.json on an Android 15 emulator

mobium storage -o state.json on an Android 15 emulator

Restore them in a later run​

device.set_storage({"cookies": [], "origins": []})

The same call from the command line, mobium storage restore state.json, printed on an Android 15 emulator:

restored 1 cookie(s) and https://mobiumapp.test's storage
{
"cookies": [
{
"name": "visited",
"value": "yes",
"domain": "mobiumapp.test",
"path": "/",
"expires": 1790759538.232578,
"secure": true
}
],
"origins": [
{
"origin": "https://mobiumapp.test",
"localStorage": [
{
"name": "visits",
"value": "2"
}
],
"sessionStorage": [
{
"name": "lastVisit",
"value": "visit 2"
}
]
}
]
}
BeforeAfter
Before: mobium storage restore state.json on an Android 15 emulatorAfter: mobium storage restore state.json on an Android 15 emulator

mobium storage restore state.json on an Android 15 emulator