session

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cookie struct {
	Path     string
	Domain   string
	SameSite string
	MaxAge   *int
	HttpOnly bool

	Secure bool
	// contains filtered or unexported fields
}

func NewCookie

func NewCookie(options *Cookie) Cookie

func (*Cookie) GetData

func (c *Cookie) GetData() CookieData

func (*Cookie) GetExpires

func (c *Cookie) GetExpires() int64

GetExpires returns the expiration time of the cookie

func (*Cookie) GetMaxAge

func (c *Cookie) GetMaxAge() int64

func (*Cookie) SetExpires

func (c *Cookie) SetExpires(expires time.Time)

SetExpires sets the max age of the cookie

func (*Cookie) SetMaxAge

func (c *Cookie) SetMaxAge(ms *int64)

type CookieData

type CookieData struct {
	OriginalMaxAge *int64
	Expires        *int64
	Secure         bool
	HttpOnly       bool
	Domain         string
	Path           string
	SameSite       string
}

type Database

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

Database is a fiber.Storage adapter backed by the DataStore's `sessionstorage` table so that HTTP sessions survive server restarts.

The opaque session payload handed over by fiber is base64-encoded and stored in the session record's Connections field; the expiration instant is stored as an RFC3339 string in the Expires field (an empty Expires means the entry never expires). Expired entries are treated as missing on Get and lazily purged from the DataStore.

func NewSessionDatabase

func NewSessionDatabase(db *db.DataStore) Database

func (Database) Close

func (s Database) Close() error

Close is a no-op; the underlying DataStore's lifecycle is managed by the server, not by the session storage adapter.

func (Database) Delete

func (s Database) Delete(key string) error

Delete deletes the value for the given key. It returns no error if the storage does not contain the key.

func (Database) DeleteWithContext added in v0.6.3

func (s Database) DeleteWithContext(_ context.Context, key string) error

DeleteWithContext deletes the value for the given key. It returns no error if the storage does not contain the key.

func (Database) Get

func (s Database) Get(key string) ([]byte, error)

Get gets the value for the given key. `nil, nil` is returned when the key does not exist or the entry has expired.

func (Database) GetWithContext added in v0.6.3

func (s Database) GetWithContext(_ context.Context, key string) ([]byte, error)

GetWithContext gets the value for the given key. `nil, nil` is returned when the key does not exist or the entry has expired.

func (Database) Reset

func (s Database) Reset() error

Reset is a no-op: the DataStore interface offers no way to enumerate or bulk-delete session records. Fiber only calls Reset via an explicit store.Reset(), which Etherpad never does.

func (Database) ResetWithContext added in v0.6.3

func (s Database) ResetWithContext(_ context.Context) error

ResetWithContext resets the storage and deletes all keys.

func (Database) Set

func (s Database) Set(key string, val []byte, exp time.Duration) error

Set stores the given value for the given key along with an expiration duration. An exp of 0 means no expiration. Empty key or value is ignored without an error, as required by the fiber.Storage contract.

func (Database) SetWithContext added in v0.6.3

func (s Database) SetWithContext(_ context.Context, key string, val []byte, exp time.Duration) error

SetWithContext stores the given value for the given key along with an expiration duration. An exp of 0 means no expiration.

type Expiration

type Expiration struct {
	Timeout *time.Timer
	Db      *int64
	Real    *int64
}

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore(db db.DataStore, refresh *int64) *MemoryStore

func (*MemoryStore) Destroy

func (m *MemoryStore) Destroy(sid string) *session.Session

func (*MemoryStore) Get

func (m *MemoryStore) Get(sid string) *session.Session

func (*MemoryStore) Set

func (m *MemoryStore) Set(sid *string, session *session.Session)

func (*MemoryStore) ShutDown

func (m *MemoryStore) ShutDown()

func (*MemoryStore) Shutdown

func (m *MemoryStore) Shutdown()

func (*MemoryStore) StartCleanup added in v0.6.0

func (m *MemoryStore) StartCleanup(interval time.Duration)

StartCleanup launches the periodic stale-session cleanup goroutine. Intended to be called once from server startup when cookie.sessionCleanup is true. Upstream #7448 / #7471.

func (*MemoryStore) StopCleanup added in v0.6.0

func (m *MemoryStore) StopCleanup()

StopCleanup terminates the background cleanup goroutine.

func (*MemoryStore) Touch

func (m *MemoryStore) Touch(sid string, session *session.Session)

func (*MemoryStore) UpdateExpirations

func (m *MemoryStore) UpdateExpirations(sid *string, session *session.Session, updateDbExp *bool) *session.Session

func (*MemoryStore) Write

func (m *MemoryStore) Write(sid string, session session.Session)

Jump to

Keyboard shortcuts

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