Skip to content

Cookie Manager (persist preferences)

Persist lightweight preferences across sessions with Cookie Manager, including optional expiration and cookie options.

Cookie Manager persists lightweight values across reloads and browser restarts — ideal for preferences and consent flags.

Use cookies when state should persist across sessions and you need to send it to the server (or you simply want the simplest persistence).

Preferences
Theme, language, UI density, dismissed banners.
Consent flags
Remember cookie consent or onboarding completion.
Simple persistence
Survives reloads and browser restarts.
Persist across sessions
Small key/value pairs
Optionally set expiration

Cookie values are strings. Store structured data only if you’re sure it’s needed (and keep it small).

tip: Avoid storing sensitive data in cookies; use server-side sessions for auth.

Prefer simple keys
Keep size small
Avoid secrets

Read cookie values in bindings, and write/remove them with actions.

Use cookieManager.key in expressions to drive UI (show/hide, text, classes).

Use cookie.set(name, value, options) to persist a preference. Options can include expires/path/domain/secure.

set(name, value, options)
Writes a cookie; can include expires and path.
remove(name, options)
Deletes a cookie (path must match).
removeAll(options)
Clears cookie state for a scope.
Use expires for long-lived prefs
Set path '/' for site-wide
Match options when removing

Bind UI theme class to a cookie value. Provide controls to set/remove it.

cookie.theme → computed class
Buttons call set/remove
Default when cookie missing

Show a banner until cookie_consent is set, then hide it permanently (until cleared).

dmx-show='!cookie.cookie_consent'
Accept → cookie.set(...)
Optional expiration (1 year)

Next, choose between cookie/session/local based on lifetime.

Pick a related tour to continue.