session

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidName

func IsValidName(name string) bool

IsValidName returns true if the session name contains only alphanumeric characters, hyphens, and underscores.

Types

type Session

type Session struct {
	Name    string
	Cookies []SessionCookie
	// contains filtered or unexported fields
}

Session represents a named cookie session.

func Load

func Load(name string) (*Session, error)

Load loads a session from disk or creates a new empty session. Expired cookies are filtered out on load.

func (*Session) Jar

func (s *Session) Jar() http.CookieJar

Jar returns an http.CookieJar that persists cookies to this session.

func (*Session) Save

func (s *Session) Save() error

Save atomically writes the session to disk.

type SessionCookie

type SessionCookie struct {
	Name     string    `json:"name"`
	Value    string    `json:"value"`
	Domain   string    `json:"domain"`
	Path     string    `json:"path,omitzero"`
	Expires  time.Time `json:"expires,omitzero"`
	Secure   bool      `json:"secure,omitzero"`
	HttpOnly bool      `json:"http_only,omitzero"`
	SameSite string    `json:"same_site,omitzero"`
}

SessionCookie represents a JSON-serializable cookie.

Jump to

Keyboard shortcuts

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