Skip to main content

Sessions & Cookies

Sessions let your server remember users across requests. Prism’s session system uses HMAC-signed cookies for tamper-proof session IDs, with pluggable storage backends for session data.

Quick Start

Enable Sessions
That’s it. Every request now has a session. The middleware:
  1. Reads the prism_session cookie from the request
  2. Verifies the HMAC-SHA256 signature
  3. Loads session data from the store
  4. Makes the session ID available via request.userInfo["sessionID"]
  5. Sets a signed cookie on the response

Session Configuration

Custom Session Config

Working with Cookies

Reading Cookies

Parse Cookies

Setting Cookies

Set a Cookie
Cookie Attributes

Custom Session Store

Implement PrismSessionStore for any backend — Redis, database, file system:
Custom Store Protocol
Database Session Store
Always set a strong secret in production. The default (random UUID) changes on every restart, invalidating all existing sessions. Use an environment variable: secret: ProcessInfo.processInfo.environment["SESSION_SECRET"]!
The built-in PrismMemorySessionStore uses PrismCache with LRU eviction — it automatically removes the oldest sessions when the limit is reached. For multi-instance deployments, use a shared store like a database.