multicookie

package module
v0.0.0-...-4e7cb03 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Multicookie

Multicookie is a gorilla sessions store implementation.

For the most part, it is similar to the built-in CookieStore. The main difference is each session value is stored in it's own cookie, rather than all stored in the same cookie. This enables storing larger values. The cookie naming scheme is <session name>-<value name>, it is the responsibility of the application to keep the <session name>- prefix clear.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiCookie

type MultiCookie struct {
	Codecs []securecookie.Codec
	// Options are use to default cookie options
	Options *sessions.Options
}

MultiCookie is a gorilla session store that saves each value to individual cookies, rather than to a single cookie. This enables larger values to be saved. All cookies are prefixed with `<sessionname>-`, it is the responsibility of the application to avoid conflict. Otherwise, it works similar to the built-in cookie store.

func New

func New(keyPairs ...[]byte) *MultiCookie

New returns a new MultiCookie.

The key options are the same as github.com/gorilla/sessions#NewCookieStore

func (*MultiCookie) Get

func (m *MultiCookie) Get(r *http.Request, name string) (*sessions.Session, error)

Get returns the caches session

func (*MultiCookie) MaxAge

func (m *MultiCookie) 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 (*MultiCookie) New

func (m *MultiCookie) New(r *http.Request, name string) (*sessions.Session, error)

New should create and return a new session.

Note that New should never return a nil session, even in the case of an error if using the Registry infrastructure to cache the session.

func (*MultiCookie) Save

Save should persist session to the underlying store implementation.

Jump to

Keyboard shortcuts

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