scs: github.com/alexedwards/scs/stores/cookiestore Index | Files

package cookiestore

import "github.com/alexedwards/scs/stores/cookiestore"

Index

Package Files

cookiestore.go

type CookieStore Uses

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

CookieStore represents the currently configured session store.

func New Uses

func New(key []byte, oldKeys ...[]byte) *CookieStore

New returns a new CookieStore instance.

The key parameter should contain the secret you want to use to authenticate and encrypt session cookies. This should be exactly 32 bytes long.

Optionally, the variadic oldKeys parameter can be used to provide an arbitrary number of old Keys. This should be used to ensure that valid cookies continue to work correctly after key rotation.

func (*CookieStore) Delete Uses

func (c *CookieStore) Delete(token string) error

Delete is a no-op. The function exists only to ensure that a CookieStore instance satisfies the scs.Store interface.

func (*CookieStore) Find Uses

func (c *CookieStore) Find(token string) (b []byte, exists bool, error error)

Find returns the session data for given cookie token. It loops through all available keys (including old keys) to try to decode the cookie. If the cookie could not be decoded, or has expired, the returned exists flag will be set to false.

func (*CookieStore) MakeToken Uses

func (c *CookieStore) MakeToken(b []byte, expiry time.Time) (token string, err error)

MakeToken creates a signed, optionally encrypted, cookie token for the provided session data. The returned token is limited to 4096 characters in length. An error will be returned if this is exceeded.

func (*CookieStore) Save Uses

func (c *CookieStore) Save(token string, b []byte, expiry time.Time) error

Save is a no-op. The function exists only to ensure that a CookieStore instance satisfies the scs.Store interface.

Package cookiestore imports 6 packages (graph) and is imported by 4 packages. Updated 2018-11-05. Refresh now. Tools for package owners.