Versions in this module Expand all Collapse all v3 v3.3.1 Dec 26, 2020 Changes in this version + const DefaultCookieName + const Version + var CookieExpireDelete = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) + var CookieExpireUnlimited = time.Now().AddDate(24, 10, 10) + var Default = New(Config{}.Validate()) + var DefaultTranscoder = defaultTranscoder + var ErrNotFound = errors.New("not found") + var ErrNotImplemented = errors.New("not implemented yet") + func AddCookie(w http.ResponseWriter, r *http.Request, cookie *http.Cookie, reclaim bool) + func AddCookieFasthttp(ctx *fasthttp.RequestCtx, cookie *fasthttp.Cookie) + func Destroy(w http.ResponseWriter, r *http.Request) + func DestroyAll() + func DestroyByID(sid string) + func DestroyFasthttp(ctx *fasthttp.RequestCtx) + func GetCookie(r *http.Request, name string) string + func GetCookieFasthttp(ctx *fasthttp.RequestCtx, name string) (value string) + func IsValidCookieDomain(domain string) bool + func OnDestroy(listeners ...DestroyListener) + func RemoveCookie(w http.ResponseWriter, r *http.Request, config Config) + func RemoveCookieFasthttp(ctx *fasthttp.RequestCtx, config Config) + func ShiftExpiration(w http.ResponseWriter, r *http.Request) + func ShiftExpirationFasthttp(ctx *fasthttp.RequestCtx) + func UpdateExpiration(w http.ResponseWriter, r *http.Request, expires time.Duration) + func UpdateExpirationFasthttp(ctx *fasthttp.RequestCtx, expires time.Duration) + func UseDatabase(db Database) + type Config struct + AllowReclaim bool + Cookie string + CookieSecureTLS bool + Decode func(cookieName string, cookieValue string, v interface{}) error + DisableSubdomainPersistence bool + Encode func(cookieName string, value interface{}) (string, error) + Encoding Encoding + Expires time.Duration + SessionIDGenerator func() string + func (c Config) Validate() Config + type Database interface + Acquire func(sid string, expires time.Duration) LifeTime + Clear func(sid string) + Delete func(sid string, key string) (deleted bool) + Get func(sid string, key string) interface{} + Len func(sid string) int + OnUpdateExpiration func(sid string, newExpires time.Duration) error + Release func(sid string) + Set func(sid string, lifetime LifeTime, key string, value interface{}, immutable bool) + Visit func(sid string, cb func(key string, value interface{})) + type DestroyListener func(sid string) + type Encoding interface + Decode func(cookieName string, cookieValue string, v interface{}) error + Encode func(cookieName string, value interface{}) (string, error) + type Entry struct + Key string + ValueRaw interface{} + func (e Entry) BoolDefault(def bool) (bool, error) + func (e Entry) Float32Default(key string, def float32) (float32, error) + func (e Entry) Float64Default(def float64) (float64, error) + func (e Entry) GetByKindOrNil(k reflect.Kind) interface{} + func (e Entry) Int64Default(def int64) (int64, error) + func (e Entry) IntDefault(def int) (int, error) + func (e Entry) String() string + func (e Entry) StringDefault(def string) string + func (e Entry) StringTrim() string + func (e Entry) Value() interface{} + type LifeTime struct + func (lt *LifeTime) Begin(d time.Duration, onExpire func()) + func (lt *LifeTime) DurationUntilExpiration() time.Duration + func (lt *LifeTime) ExpireNow() + func (lt *LifeTime) HasExpired() bool + func (lt *LifeTime) Revive(onExpire func()) + func (lt *LifeTime) Shift(d time.Duration) + type Marshaler interface + Marshal func(interface{}) ([]byte, error) + type Session struct + Lifetime LifeTime + func Start(w http.ResponseWriter, r *http.Request) *Session + func StartFasthttp(ctx *fasthttp.RequestCtx) *Session + func (s *Session) Clear() + func (s *Session) ClearFlashes() + func (s *Session) Decrement(key string, n int) (newValue int) + func (s *Session) Delete(key string) bool + func (s *Session) DeleteFlash(key string) + func (s *Session) Destroy() + func (s *Session) Get(key string) interface{} + func (s *Session) GetAll() map[string]interface{} + func (s *Session) GetBoolean(key string) (bool, error) + func (s *Session) GetBooleanDefault(key string, defaultValue bool) bool + func (s *Session) GetFlash(key string) interface{} + func (s *Session) GetFlashString(key string) string + func (s *Session) GetFlashStringDefault(key string, defaultValue string) string + func (s *Session) GetFlashes() map[string]interface{} + func (s *Session) GetFloat32(key string) (float32, error) + func (s *Session) GetFloat32Default(key string, defaultValue float32) float32 + func (s *Session) GetFloat64(key string) (float64, error) + func (s *Session) GetFloat64Default(key string, defaultValue float64) float64 + func (s *Session) GetInt(key string) (int, error) + func (s *Session) GetInt64(key string) (int64, error) + func (s *Session) GetInt64Default(key string, defaultValue int64) int64 + func (s *Session) GetIntDefault(key string, defaultValue int) int + func (s *Session) GetString(key string) string + func (s *Session) GetStringDefault(key string, defaultValue string) string + func (s *Session) HasFlash() bool + func (s *Session) ID() string + func (s *Session) Increment(key string, n int) (newValue int) + func (s *Session) IsNew() bool + func (s *Session) PeekFlash(key string) interface{} + func (s *Session) Set(key string, value interface{}) + func (s *Session) SetFlash(key string, value interface{}) + func (s *Session) SetImmutable(key string, value interface{}) + func (s *Session) Visit(cb func(k string, v interface{})) + type Sessions struct + func New(cfg Config) *Sessions + func (s *Sessions) Destroy(w http.ResponseWriter, r *http.Request) + func (s *Sessions) DestroyAll() + func (s *Sessions) DestroyByID(sid string) + func (s *Sessions) DestroyFasthttp(ctx *fasthttp.RequestCtx) + func (s *Sessions) OnDestroy(listeners ...DestroyListener) + func (s *Sessions) ShiftExpiration(w http.ResponseWriter, r *http.Request) + func (s *Sessions) ShiftExpirationFasthttp(ctx *fasthttp.RequestCtx) + func (s *Sessions) Start(w http.ResponseWriter, r *http.Request) *Session + func (s *Sessions) StartFasthttp(ctx *fasthttp.RequestCtx) *Session + func (s *Sessions) UpdateExpiration(w http.ResponseWriter, r *http.Request, expires time.Duration) error + func (s *Sessions) UpdateExpirationFasthttp(ctx *fasthttp.RequestCtx, expires time.Duration) error + func (s *Sessions) UseDatabase(db Database) + type Store []Entry + func (r *Store) Get(key string) interface{} + func (r *Store) GetBool(key string) (bool, error) + func (r *Store) GetBoolDefault(key string, def bool) bool + func (r *Store) GetDefault(key string, def interface{}) interface{} + func (r *Store) GetEntry(key string) *Entry + func (r *Store) GetFloat64(key string) (float64, error) + func (r *Store) GetFloat64Default(key string, def float64) float64 + func (r *Store) GetInt(key string) (int, error) + func (r *Store) GetInt64(key string) (int64, error) + func (r *Store) GetInt64Default(key string, def int64) int64 + func (r *Store) GetIntDefault(key string, def int) int + func (r *Store) GetString(key string) string + func (r *Store) GetStringDefault(key string, def string) string + func (r *Store) GetStringTrim(name string) string + func (r *Store) Len() int + func (r *Store) Remove(key string) bool + func (r *Store) Reset() + func (r *Store) Save(key string, value interface{}, immutable bool) (Entry, bool) + func (r *Store) Set(key string, value interface{}) (Entry, bool) + func (r *Store) SetImmutable(key string, value interface{}) (Entry, bool) + func (r *Store) Visit(visitor func(key string, value interface{})) + func (r Store) Serialize() []byte + type Transcoder interface + type Unmarshaler interface + Unmarshal func([]byte, interface{}) error Other modules containing this package github.com/bh90210/go-sessions