class

Session::Base

Inherits JSON::Serializable < Reference < Object

Base class for session data

Subclass this to define your session's data structure. Override authenticated? to reflect your authentication logic.

Example:

class UserSession < Session::Base
property? authenticated : Bool = false
property username : String? = nil

def authenticated? : Bool
  @authenticated
end
end

Constructors

new(pull : JSON::PullParser)
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source

Instance methods

==(other : Base)
Source
authenticated?
Source
client_fingerprint

The client the session was first used from, when session binding is enabled.

Source
client_fingerprint=(client_fingerprint : ClientFingerprint | Nil)

The client the session was first used from, when session binding is enabled.

Source
created_at
Source
expired?
Source
expires_at

Required in a stored or signed payload (see after_initialize): the default is for new only.

Source
expires_at=(expires_at : Time)

Required in a stored or signed payload (see after_initialize): the default is for new only.

Source
flash

Messages for the next request. They belong to the session, so they are saved with it and reach only the visitor they were meant for.

Source
session_id
Source
time_until_expiry

Get time remaining until session expires

Source
touch

Extend the session expiration time (for sliding expiration)

Source
valid?
Source