Skip to main content

Module sessions

Module sessions 

Source
Expand description

Session management for What framework

Provides session storage with pluggable backends:

  • SQLite (default, for local development and single-server deployments)
  • Cloudflare Workers KV (for globally distributed, durable sessions)

Structs§

KvSessionStore
Session store backed by Cloudflare Workers KV via REST API
Session
Session data structure
SqliteSessionStore
Session store backed by SQLite with connection pooling. Uses r2d2 for concurrent reads and spawn_blocking to avoid blocking the async runtime.

Enums§

AtomicMutation
Atomic session mutation operation — used by the server to apply mutations at the SQL level
SessionBackend
Pluggable session storage backend

Constants§

CSRF_TOKEN_KEY
Reserved session key for the CSRF token

Functions§

apply_mutation_in_memory
Apply a mutation to in-memory session data (used for KV fallback and testing).
build_clear_session_cookie
Build a Set-Cookie header that expires the session cookie (used on logout).
build_session_cookie
Build Set-Cookie header value
generate_csrf_token
Generate a cryptographically secure CSRF token Returns 64 hex characters (32 bytes of random data)
generate_session_id
Generate a cryptographically secure session ID Returns 128 hex characters (64 bytes of random data)
parse_session_cookie
Parse session ID from cookie header