Skip to main content

Storage · SetStorage · ClearStorage

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​

func (d *Device) Storage(ctx context.Context) (*StorageState, error)

Storage answers the current page's storage state: its cookies and its origin's localStorage and sessionStorage.

SetStorage​

func (d *Device) SetStorage(ctx context.Context, state StorageState) error

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

ClearStorage​

func (d *Device) ClearStorage(ctx context.Context) error

ClearStorage empties the current page's cookies, localStorage and sessionStorage.

Examples​

Save the WebView's cookies and web storage​

state, err := dev.Storage(ctx)
if err != nil {
return err
}
fmt.Println(len(state.Cookies), "cookies,", len(state.Origins), "origins")

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​

// Empty slices, not nil: nil would go on the wire as null.
state := mobium.StorageState{Cookies: []mobium.Cookie{}, Origins: []mobium.OriginStorage{}}
if err := dev.SetStorage(ctx, state); err != nil {
return err
}

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