Versions in this module Expand all Collapse all v1 v1.5.0 Mar 20, 2025 Changes in this version + var ErrDuplicateID = errors.New("duplicate ID") + var ErrNotOwner = errors.New("session can be managed only by its owner") + var ErrUnauthorized = errors.New("unauthorized") + func DefaultGenID() string + func DefaultReject(err error) http.Handler + func NewContext(ctx context.Context, s Session) context.Context + type Manager struct + func NewManager(s Store, opts ...Option) *Manager + func (m *Manager) Auth(next http.Handler) http.Handler + func (m *Manager) Clone(opts ...Option) *Manager + func (m *Manager) Defaults() + func (m *Manager) FetchAll(ctx context.Context) ([]Session, error) + func (m *Manager) Init(w http.ResponseWriter, r *http.Request, key string, mm ...Meta) error + func (m *Manager) Public(next http.Handler) http.Handler + func (m *Manager) Revoke(ctx context.Context, w http.ResponseWriter) error + func (m *Manager) RevokeAll(ctx context.Context, w http.ResponseWriter) error + func (m *Manager) RevokeByID(ctx context.Context, id string) error + func (m *Manager) RevokeByIDExt(ctx context.Context, id string) error + func (m *Manager) RevokeByUserKey(ctx context.Context, key string) error + func (m *Manager) RevokeOther(ctx context.Context) error + type Meta func(map[string]string) + func MetaEntry(key, value string) Meta + type Option func(*Manager) + func CookieName(n string) Option + func Domain(d string) Option + func ExpiresIn(e time.Duration) Option + func GenID(g func() string) Option + func HttpOnly(h bool) Option + func Path(p string) Option + func Reject(r func(error) http.Handler) Option + func SameSite(s http.SameSite) Option + func Secure(s bool) Option + func Validate(v bool) Option + func WithAgent(w bool) Option + func WithIP(w bool) Option + type Session struct + Agent struct{ ... } + CreatedAt time.Time + Current bool + ExpiresAt time.Time + ID string + IP net.IP + Meta map[string]string + UserKey string + func FromContext(ctx context.Context) (Session, bool) + func (s Session) IsValid(r *http.Request) bool + type Store interface + Create func(ctx context.Context, s Session) error + DeleteByID func(ctx context.Context, id string) error + DeleteByUserKey func(ctx context.Context, key string, expID ...string) error + FetchByID func(ctx context.Context, id string) (Session, bool, error) + FetchByUserKey func(ctx context.Context, key string) ([]Session, error)