Quick Start
Step 1: Define Session Data
require "session"
struct UserSession
include Session::SessionData
property user_id : Int64?
property username : String?
property email : String?
property role : String = "guest"
property login_time : Time?
def authenticated? : Bool
!user_id.nil?
end
def admin? : Bool
role == "admin"
end
endStep 2: Configure Session
Step 3: Use Sessions
Create a Session
Retrieve a Session
Update a Session
Delete a Session
Step 4: HTTP Integration
Step 5: Add Flash Messages
Complete Example
Next Steps
Last updated
Was this helpful?