Help us shape the future of Go! Take the 2026 Go Developer Survey

sessionstore

package
v1.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sessionstore implements the scs.Store interface on top of the cms_sessions table. It exists (rather than using scs's own pgxstore) so the table name carries the cms_ prefix and can live in a database shared with the host application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store persists sessions in the cms_sessions table.

func New

func New(db *sqldb.DB) *Store

New returns a Store that deletes expired sessions once an hour.

func NewWithCleanupInterval

func NewWithCleanupInterval(db *sqldb.DB, interval time.Duration) *Store

NewWithCleanupInterval returns a Store whose background cleanup runs at the given interval. A zero or negative interval disables cleanup.

func (*Store) Commit

func (s *Store) Commit(token string, data []byte, expiry time.Time) error

Commit inserts or updates a session token with data and expiry.

func (*Store) CommitCtx added in v1.2.2

func (s *Store) CommitCtx(ctx context.Context, token string, data []byte, expiry time.Time) error

CommitCtx is Commit under a write context: deadlined, but not cancellable by the request. See sessiondata.WriteContext.

func (*Store) Delete

func (s *Store) Delete(token string) error

Delete removes a session token.

func (*Store) DeleteCtx added in v1.2.2

func (s *Store) DeleteCtx(ctx context.Context, token string) error

DeleteCtx is Delete under a write context. A logout that did not land because the browser hung up would leave a session that still works, so this one in particular outlives the request that asked for it.

func (*Store) Find

func (s *Store) Find(token string) ([]byte, bool, error)

Find returns the data for a session token, if present and unexpired.

func (*Store) FindCtx added in v1.2.2

func (s *Store) FindCtx(ctx context.Context, token string) ([]byte, bool, error)

FindCtx is Find under the request's own context, so a lookup for a visitor who is no longer there stops with them.

func (*Store) StopCleanup

func (s *Store) StopCleanup()

StopCleanup halts the background cleanup goroutine, for tests or graceful shutdown. It returns once the goroutine has actually stopped, and is safe to call any number of times — including on a store built with cleanup disabled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL