Documentation
¶
Overview ¶
Package session contains methods and objects for managing user sessions.
Index ¶
- Variables
- func Clear(ctx context.Context) error
- func Remove(ctx context.Context, key string) error
- func Renew(ctx context.Context) error
- func Restore[T any](ctx context.Context, key string) (T, error)
- func Save[T any](ctx context.Context, key string, obj T) error
- func SaveAndCommit[T any](ctx context.Context, key string, obj T) error
Constants ¶
This section is empty.
Variables ¶
var Load = sync.OnceValue(func() *scs.SessionManager { manager := scs.New() manager.Store = store.New() manager.Lifetime = sessionLifetime manager.Cookie.Name = strings.ToLower(config.GetAppName()) + "_session" manager.Cookie.Secure = true manager.Cookie.HttpOnly = true manager.Cookie.SameSite = http.SameSiteLaxMode return manager })
Functions ¶
func Clear ¶
Clear deletes the session data from the session store and sets the session status to Destroyed. Any further operations in the same request cycle will result in a new session being created.
func Renew ¶ added in v0.51.0
Renew updates the session data to have a new session token while retaining the current session data. The session lifetime is also reset and the session data status will be set to Modified. The old session token and accompanying data are deleted from the session store.
func Restore ¶
Restore retrieves an object from the session storage with the given key. If there is an error retrieving the object as the given type a non-nill error containing details will be returned.
Types ¶
This section is empty.