module Session

Defined in:

base.cr
binding.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

Macro Summary

Class Method Detail

def self.config #

[View source]
def self.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).


[View source]
def self.session #

[View source]

Macro Detail

macro 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

[View source]