module Session
Defined in:
base.crbinding.cr
cluster.cr
compression.cr
configuration.cr
connection_pool.cr
flash.cr
handlers/authentication_handler.cr
handlers/commit_on_write.cr
handlers/session_handler.cr
metrics.cr
presets.cr
redis_utils.cr
retry.cr
session.cr
store.cr
stores/clustered_redis_store.cr
stores/cookie_store.cr
stores/memory_store.cr
stores/redis_store.cr
Constant Summary
-
CONFIG =
Configuration.new -
Log =
::Log.for("session")
Class Method Summary
- .config
-
.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 (SessionHandlerchecks again on each request). - .session
Macro Summary
-
use_store(store_type)
Injects a typed
storeproperty intoSession::Configurationfor the given store type.
Class Method Detail
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).
Macro Detail
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