Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer encode the session map to JSON.
func (JSONSerializer) Deserialize ¶
func (s JSONSerializer) Deserialize(d []byte, ss *sessions.Session) error
Deserialize back to map[string]interface{}
type MemStore ¶
type MemStore struct { Codecs []securecookie.Codec Options *sessions.Options // contains filtered or unexported fields }
MemStore is an in-memory implementation of gorilla/sessions, suitable for use in tests and development environments. Do not use in production. Values are cached in a map. The cache is protected and can be used by multiple goroutines.
func NewMemStore ¶
NewMemStore returns a new MemStore.
Keys are defined in pairs to allow key rotation, but the common case is to set a single authentication key and optionally an encryption key.
The first key in a pair is used for authentication and the second for encryption. The encryption key can be set to nil or omitted in the last pair, but the authentication key is required in all pairs.
It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.
Use the convenience function securecookie.GenerateRandomKey() to create strong keys.
func (*MemStore) Get ¶
Get returns a session for the given name after adding it to the registry.
It returns a new session if the sessions doesn't exist. Access IsNew on the session to check if it is an existing session or a new one.
It returns a new session and an error if the session exists but could not be decoded.
func (*MemStore) MaxAge ¶
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.