session

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(c fiber.Ctx, key string)

Delete deletes a value from the session.

func Destroy

func Destroy(c fiber.Ctx)

Destroy destroys the session.

func Get

func Get[T any](c fiber.Ctx, key string) T

Get fetches a value from the session as T. If the session doesn't contain a T then the zero value of T is returned.

func GetID

func GetID(c fiber.Ctx) string

GetID returns the session ID.

func GetOnce

func GetOnce[T any](c fiber.Ctx, key string) T

GetOnce fetches a value from the session as T, then deletes it. If the session doesn't contain a T then the zero value of T is returned.

func New

func New(config *Config) fiber.Handler

New initialises the session and returns a middleware handler.

func Regenerate

func Regenerate(c fiber.Ctx)

Regenerate regenerates the session.

func Set

func Set[T any](c fiber.Ctx, key string, value T)

Set stores a value in the session. If T is a custom type then it may need to be registered with gob.Register first.

func TryGet

func TryGet[T any](c fiber.Ctx, key string) (T, bool)

TryGet fetches a value from the session as T, returning the value and a boolean indicating whether the value was present in the session.

func TryGetOnce

func TryGetOnce[T any](c fiber.Ctx, key string) (T, bool)

TryGetOnce fetches a value from the session as T, then deletes it from the session.

Types

type Config

type Config struct {
	Table        string        // The table to store the session data in.
	CookieSecure bool          // Whether the cookie should be HTTPS-only.
	IdleTimeout  time.Duration // How long the session cookie should last.
	DSN          string
}

Jump to

Keyboard shortcuts

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