Expand description
Cross-platform cookie management for Dioxus fullstack applications.
Dioxus apps can target web, desktop, iOS, and Android from a single codebase. Native platforms lack built-in cookie storage—when a server function sets a cookie, native apps silently discard it. dioxus-cookie provides a unified cookie API that works across all supported platforms.
§Quick Start
ⓘ
fn main() {
dioxus_cookie::init(); // Call before dioxus::launch()
dioxus::launch(App);
}
#[server]
async fn login(credentials: Credentials) -> Result<(), ServerFnError> {
dioxus_cookie::set("session", &token, &CookieOptions::default())?;
Ok(())
}§Platform Behavior
| Platform | Storage |
|---|---|
| Server | HTTP Set-Cookie headers |
| Browser | document.cookie |
| Desktop | System keyring |
| iOS | Keychain |
| Android | KeyStore (default) or encrypted file (android-file feature) |
§Features
server— Server-side cookie handling via HTTP headersdesktop— Desktop platforms with system keyring storagemobile— iOS/Android with Keychain/KeyStore storageandroid-file— Force encrypted file storage on Android (skip KeyStore)mobile-sim— Mobile + file fallback for simulator/emulator developmentfile-store— Encrypted file fallback (see security note below)
§File Storage Fallback
The file-store feature provides encrypted file-based storage for environments
where the system keychain is unavailable (iOS Simulator, Android Emulator,
Linux without D-Bus, CI/CD pipelines, Docker containers).
Security limitations:
- Debug builds only — automatically disabled in release builds
- Obfuscation, not protection — deters casual inspection but does not protect against local attackers with file system access
- Not for production — production apps must use real keychain storage
Structs§
- Cookie
Error - Error type for cookie operations.
- Cookie
Options - Configuration options for setting cookies.
Enums§
- Same
Site - Cross-site request cookie policy (SameSite attribute).
Functions§
- clear
- Deletes a cookie by name.
- get
- Retrieves a cookie value by name.
- get_
internal - Retrieves a cookie value, bypassing the
HttpOnlyrestriction. - get_
storage_ type - Returns the active storage backend type.
- init
- Initialize the cookie system.
- list_
names - Lists names of all accessible cookies.
- set
- Sets a cookie with the given name, value, and options.