user

package
v0.0.0-...-1c65738 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SessionFromHttpResponse

func SessionFromHttpResponse[T any](manager *SessionManager[T], httpResponse *http.Response) *T

Types

type Session

type Session[TData any] struct {
	Data    TData
	Expires time.Time
}

type SessionManager

type SessionManager[TData any] struct {
	// contains filtered or unexported fields
}

func NewSessionManager

func NewSessionManager[TData any](sessionLifetime time.Duration) *SessionManager[TData]

NewSessionManager creates a new session manager. It uses in-memory storage.

func (*SessionManager[TData]) Create

func (m *SessionManager[TData]) Create(response http.ResponseWriter, values TData)

Create creates a new session and sets a session cookie. The given values are stored in the session, which can be retrieved later using Get.

func (*SessionManager[TData]) Destroy

func (m *SessionManager[TData]) Destroy(response http.ResponseWriter, request *http.Request)

func (*SessionManager[TData]) Get

func (m *SessionManager[TData]) Get(request *http.Request) *TData

Get retrieves the session for the given request. The session is retrieved using the session cookie. If no session is found, nil is returned.

func (*SessionManager[TData]) PruneSessions

func (m *SessionManager[TData]) PruneSessions()

PruneSessions removes expired sessions.

func (*SessionManager[TData]) SessionCount

func (m *SessionManager[TData]) SessionCount() int

Jump to

Keyboard shortcuts

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