Versions in this module Expand all Collapse all v0 v0.1.0 Sep 28, 2026 Changes in this version + const DefaultCookieName + const DefaultTTL + var ErrExpired = errors.New("sessionx: session expired") + var ErrInvalidTransition = errors.New("sessionx: invalid status transition") + var ErrNotFound = errors.New("sessionx: session not found") + var ErrRevoked = errors.New("sessionx: session revoked") + var ErrTampered = errors.New("sessionx: payload signature mismatch") + var ErrUnsupported = errors.New("sessionx: operation unsupported by this store") + func DeviceFromRequest(r *http.Request) (Device, Client) + func DeviceFromUA(ua string) (Device, Client) + func EqualID(a, b string) bool + func NewContext(ctx context.Context, s *Session) context.Context + func NewID() (string, error) + type Client struct + AppName string + AutomationName string + BotName string + Kind string + SpoofScore float64 + func (c Client) Human() bool + type CookieConfig struct + AllowScript bool + Domain string + Insecure bool + Name string + Path string + SameSite http.SameSite + func DefaultCookie() CookieConfig + type Device struct + Brand string + Browser string + BrowserVersion string + Code string + Confidence float64 + Family string + Name string + OS string + OSVersion string + Raw string + Type string + func (d Device) Known() bool + type Input struct + Client Client + Data map[string]any + Device Device + Forwarded string + Locale string + LocaleSource string + RemoteAddr string + UserAgent string + UserID string + type Manager struct + func NewManager(store Store, opts Options) *Manager + func (m *Manager) Clear(w http.ResponseWriter, c CookieConfig) + func (m *Manager) Collect(ctx context.Context, in Input) (*Session, error) + func (m *Manager) Get(ctx context.Context, id string) (*Session, error) + func (m *Manager) InputFrom(r *http.Request, userID string) Input + func (m *Manager) Issue(w http.ResponseWriter, s *Session, c CookieConfig) error + func (m *Manager) ListUser(ctx context.Context, userID string) ([]*Session, error) + func (m *Manager) Middleware(c CookieConfig) func(http.Handler) http.Handler + func (m *Manager) Renew(ctx context.Context, id string) (*Session, error) + func (m *Manager) Revoke(ctx context.Context, id string) error + func (m *Manager) RevokeUser(ctx context.Context, userID string) (int, error) + func (m *Manager) Touch(ctx context.Context, id string) (*Session, error) + type Network struct + Forwarded string + IP string + func NetworkFrom(remoteAddr, forwarded string, trusted []netip.Prefix) Network + type Options struct + IdleTimeout time.Duration + Locale *alx.Resolver + MaxPerUser int + Now func() time.Time + TTL time.Duration + TrustedProxies []netip.Prefix + type Session struct + Client Client + CreatedAt time.Time + Data map[string]any + Device Device + ExpiresAt time.Time + ID string + LastSeen time.Time + Locale string + LocaleSource string + Network Network + RenewedAt time.Time + Status Status + UserID string + func FromContext(ctx context.Context) (*Session, bool) + func (s *Session) Clone() *Session + func (s *Session) Expired(now time.Time) bool + func (s *Session) IdleSince(now time.Time, idle time.Duration) bool + func (s *Session) MoveTo(next Status) error + type Status string + const StatusActive + const StatusExpired + const StatusIdle + const StatusRevoked + func (s Status) CanMoveTo(next Status) bool + func (s Status) Err() error + func (s Status) String() string + func (s Status) Terminal() bool + func (s Status) Valid() bool + type Store interface + Delete func(ctx context.Context, id string) error + DeleteByUser func(ctx context.Context, userID string) (int, error) + ListByUser func(ctx context.Context, userID string) ([]*Session, error) + Load func(ctx context.Context, id string) (*Session, error) + Save func(ctx context.Context, s *Session) error + type Tokenizer interface + Token func(s *Session) (string, error)