session

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHelpers

func AddHelpers(next http.Handler) http.Handler

func FromCtx

func FromCtx(ctx context.Context) *sessions.Session

FromCtx returns the session from the context.

func New

func New(secret, name string, options ...Option) *session

func RegisterSessionTypes

func RegisterSessionTypes(types ...any)

RegisterSessionTypes registers those custom types that will be stored in the session.

Types

type Option

type Option func(*sessions.CookieStore)

Option for the session middleware

func WithDomain

func WithDomain(domain string) Option

Set the domain for the application session This is useful when you want to share the session between subdomains.

func WithHTTPOnly

func WithHTTPOnly(httpOnly bool) Option

WithHTTPOnly sets the HttpOnly flag on the session cookie.

func WithMaxAge

func WithMaxAge(maxAge int) Option

WithMaxAge sets the maximum age for the session cookie. A negative value means that the cookie is deleted when the browser is closed.

func WithPath

func WithPath(path string) Option

func WithSameSite

func WithSameSite(sameSite http.SameSite) Option

WithSameSite value for the SameSite option on the session cookie.

func WithSecure

func WithSecure(secure bool) Option

WithSecure value for the Secure flag on the session cookie.

func WithSecureFlag

func WithSecureFlag(secure bool) Option

WithSecure sets the Secure flag on the session cookie.

Jump to

Keyboard shortcuts

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