sessions

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: MIT Imports: 12 Imported by: 0

README

Sessions

Sessions package for Go, use stdlib and secure cookie.

Since the experience for gorilla/sessions was s*it, we decided to write our own.

This package refers to the session module in goravel/framework.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CtxKey     = "session" // session default context key
	CookieName = "session" // session default cookie name
)

Functions

This section is empty.

Types

type Manager

type Manager struct {
	Codec      securecookie.Codec
	Lifetime   int
	GcInterval int
	// contains filtered or unexported fields
}

func NewManager

func NewManager(option *ManagerOptions) (*Manager, error)

NewManager creates a new session manager.

func (*Manager) AcquireSession

func (m *Manager) AcquireSession() *Session

func (*Manager) BuildSession

func (m *Manager) BuildSession(name string, driver ...string) (*Session, error)

func (*Manager) Extend

func (m *Manager) Extend(driver string, handler driver.Driver) error

func (*Manager) GetSession

func (m *Manager) GetSession(r *http.Request, key ...any) (*Session, error)

func (*Manager) HasSession

func (m *Manager) HasSession(r *http.Request, key ...any) bool

func (*Manager) ReleaseSession

func (m *Manager) ReleaseSession(session *Session)

type ManagerOptions

type ManagerOptions struct {
	// 32 bytes string to encrypt session data
	Key string
	// session lifetime in minutes
	Lifetime int
	// session garbage collection interval in minutes
	GcInterval int
	// Disable default file driver if set to true
	DisableDefaultDriver bool
}

type Session

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

func (*Session) All

func (s *Session) All() map[string]any

func (*Session) Exists

func (s *Session) Exists(key string) bool

func (*Session) Flash

func (s *Session) Flash(key string, value any) *Session

func (*Session) Flush

func (s *Session) Flush() *Session

func (*Session) Forget

func (s *Session) Forget(keys ...string) *Session

func (*Session) Get

func (s *Session) Get(key string, defaultValue ...any) any

func (*Session) GetID

func (s *Session) GetID() string

func (*Session) GetName

func (s *Session) GetName() string

func (*Session) Has

func (s *Session) Has(key string) bool

func (*Session) Invalidate

func (s *Session) Invalidate() error

func (*Session) IsStarted

func (s *Session) IsStarted() bool

func (*Session) Keep

func (s *Session) Keep(keys ...string) *Session

func (*Session) Missing

func (s *Session) Missing(key string) bool

func (*Session) Now

func (s *Session) Now(key string, value any) *Session

func (*Session) Only

func (s *Session) Only(keys []string) map[string]any

func (*Session) Pull

func (s *Session) Pull(key string, def ...any) any

func (*Session) Put

func (s *Session) Put(key string, value any) *Session

func (*Session) Reflash

func (s *Session) Reflash() *Session

func (*Session) Regenerate

func (s *Session) Regenerate(destroy ...bool) error

func (*Session) Remove

func (s *Session) Remove(key string) any

func (*Session) Save

func (s *Session) Save() error

func (*Session) SetID

func (s *Session) SetID(id string) *Session

func (*Session) SetName

func (s *Session) SetName(name string) *Session

func (*Session) Start

func (s *Session) Start() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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