module

Session

Constants

CONFIG = Configuration.new
Log = ::Log.for("session")

Class methods

config
Source
configure

Applies the block to CONFIG, then checks it: a store that encrypts with the secret fails here, at boot, when the secret is unusable (SessionHandler checks again on each request).

Source
session
Source

Macros

use_store(store_type)

Injects a typed store property into Session::Configuration for the given store type.

Crystal's invariant generics mean CookieStore(UserSession) cannot be assigned to Store(Base)?. Calling use_store reopens Configuration in the library's own namespace so that the property carries the exact concrete type, keeping your application code free of class-reopen boilerplate.

Call this before Session.configure:

Session.use_store(Session::CookieStore(UserSession))

Session.configure do |c|
  # The secret is read from SESSION_SECRET (random per process in development without it)
  c.store = Session::CookieStore(UserSession).new
end
Source

Nested types