cookie

package
v0.52.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const UserSessionKey string = "user_id"

Variables

This section is empty.

Functions

This section is empty.

Types

type UserSessionStore

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

func NewUserSessionStore

func NewUserSessionStore(fs ...UserSessionStoreOpt) (*UserSessionStore, error)

func (*UserSessionStore) Get

func (store *UserSessionStore) Get(r *http.Request, name string) (*sessions.Session, error)

Get Fetches a session for a given name after it has been added to the registry.

func (*UserSessionStore) GetName

func (store *UserSessionStore) GetName() string

func (*UserSessionStore) MaxAge

func (store *UserSessionStore) MaxAge(age int)

MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.

func (*UserSessionStore) MaxLength

func (store *UserSessionStore) MaxLength(l int)

MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new PGStore is 4096. PostgreSQL allows for max value sizes of up to 1GB (http://www.postgresql.org/docs/current/interactive/datatype-character.html)

func (*UserSessionStore) New

func (store *UserSessionStore) New(r *http.Request, name string) (*sessions.Session, error)

func (*UserSessionStore) Save

func (store *UserSessionStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error

Save saves the given session into the database and deletes cookies if needed

type UserSessionStoreOpt

type UserSessionStoreOpt func(*UserSessionStoreOpts)

func WithCookieAllowInsecure

func WithCookieAllowInsecure(allow bool) UserSessionStoreOpt

func WithCookieDomain

func WithCookieDomain(domain string) UserSessionStoreOpt

func WithCookieName

func WithCookieName(name string) UserSessionStoreOpt

func WithCookieSecrets

func WithCookieSecrets(secrets ...string) UserSessionStoreOpt

type UserSessionStoreOpts

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

Jump to

Keyboard shortcuts

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