Documentation
¶
Overview ¶
Package session provides session management using Fiber's session middleware.
Index ¶
- type Config
- type Driver
- type Manager
- type Session
- func (s *Session) All() map[string]any
- func (s *Session) CreatedAt() time.Time
- func (s *Session) Destroy() error
- func (s *Session) Flash(key string, value any) error
- func (s *Session) Flush() error
- func (s *Session) Forget(key string) error
- func (s *Session) Get(key string) any
- func (s *Session) GetBool(key string) bool
- func (s *Session) GetInt(key string) int
- func (s *Session) GetString(key string) string
- func (s *Session) Has(key string) bool
- func (s *Session) ID() string
- func (s *Session) Keep(keys ...string) error
- func (s *Session) LastActivity() time.Time
- func (s *Session) Pull(key string) any
- func (s *Session) Reflash() error
- func (s *Session) Regenerate() error
- func (s *Session) Save() error
- func (s *Session) Set(key string, value any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Expiration is the session expiration time.
Expiration time.Duration
// CookieName is the name of the session cookie.
CookieName string
// CookiePath is the path of the session cookie.
CookiePath string
// CookieDomain is the domain of the session cookie.
CookieDomain string
// CookieSecure indicates if the cookie should only be sent over HTTPS.
CookieSecure bool
// CookieHTTPOnly indicates if the cookie should be HTTP only.
CookieHTTPOnly bool
// CookieSameSite controls the SameSite attribute.
CookieSameSite string
// KeyLookup is the key lookup format (e.g., "cookie:session_id").
KeyLookup string
// Storage is the storage driver name.
Storage string
}
Config holds session configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default session configuration.
type Driver ¶
type Driver interface {
// Get retrieves session data.
Get(id string) (map[string]any, error)
// Set stores session data.
Set(id string, data map[string]any, expiration time.Duration) error
// Delete removes session data.
Delete(id string) error
// Clear removes all sessions.
Clear() error
}
Driver is the interface for session storage drivers.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages sessions.
func NewManager ¶
NewManager creates a new session manager.
func (*Manager) Middleware ¶
Middleware returns Fiber middleware for session handling.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session wraps Fiber's session with Laravel-like API.
func GetFromContext ¶
GetFromContext retrieves the session from Fiber context.
func (*Session) LastActivity ¶
LastActivity returns the last activity time.
func (*Session) Regenerate ¶
Regenerate regenerates the session ID.
Click to show internal directories.
Click to hide internal directories.