class

Alumna::Session

Inherits Reference < Object

Binds a SessionStore to cookie flags. Keep one instance for the rule and for start/stop/rotate so the cookie name and flags stay in sync.

sessions = Alumna::Session.new(Alumna::MemorySessionStore.new(ttl: 24.hours)) app.before sessions.rule app.before sessions.rule(required: false), on: :find started = sessions.start(ctx, Alumna.hash(user_id: id)) next ServiceError.internal(started.message) if started.is_a?(StoreError)

Constants

DEFAULT_COOKIE = "alumna.sid"
DEFAULT_SKIP = ["internal", "local"]
DEFAULT_STORE_KEY = "session"

Constructors

Class methods

rotate(ctx : RuleContext, store : SessionStore, data : Hash(String, AnyData), ttl : Time::Span | Nil = nil) : String | StoreError
Source
start(ctx : RuleContext, store : SessionStore, data : Hash(String, AnyData), ttl : Time::Span | Nil = nil) : String | StoreError

Class helpers use the default cookie name and flags. Prefer an instance when you set cookie, secure, or same_site on the rule.

Source
stop(ctx : RuleContext, store : SessionStore) : Nil | StoreError
Source

Instance methods

rotate(ctx : RuleContext, data : Hash(String, AnyData), ttl : Time::Span | Nil = nil) : String | StoreError
Source
rule(*, required : Bool = @required) : Rule

required overrides the constructor flag for this rule only. start, stop, and rotate keep the constructor cookie flags.

Source
start(ctx : RuleContext, data : Hash(String, AnyData), ttl : Time::Span | Nil = nil) : String | StoreError
Source
stop(ctx : RuleContext) : Nil | StoreError
Source
store
Source
store_key
Source