Documentation
¶
Overview ¶
Package cookie provides a cookie based implementation of session store and loader.
Index ¶
Constants ¶
View Source
const ( // ChunkedCanaryByte is the byte value used as a canary prefix to distinguish if // the cookie is multi-part or not. This constant *should not* be valid // base64. It's important this byte is ASCII to avoid UTF-8 variable sized runes. // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#Directives ChunkedCanaryByte byte = '%' // MaxChunkSize sets the upper bound on a cookie chunks payload value. // Note, this should be lower than the actual cookie's max size (4096 bytes) // which includes metadata. MaxChunkSize = 3800 // MaxNumChunks limits the number of chunks to iterate through. Conservatively // set to prevent any abuse. MaxNumChunks = 5 )
Variables ¶
This section is empty.
Functions ¶
func NewStore ¶
func NewStore(opts *Options, encoder encoding.MarshalUnmarshaler) (sessions.SessionStore, error)
NewStore returns a new store that implements the SessionStore interface using http cookies.
Types ¶
type Store ¶
type Store struct { Name string Domain string Expire time.Duration HTTPOnly bool Secure bool // contains filtered or unexported fields }
Store implements the session store interface for session cookies.
func NewCookieLoader ¶
func NewCookieLoader(opts *Options, dencoder encoding.Unmarshaler) (*Store, error)
NewCookieLoader returns a new store that implements the SessionLoader interface using http cookies.
func (*Store) ClearSession ¶
func (cs *Store) ClearSession(w http.ResponseWriter, r *http.Request)
ClearSession clears the session cookie from a request
func (*Store) LoadSession ¶
LoadSession returns a State from the cookie in the request.
func (*Store) SaveSession ¶
SaveSession saves a session state to a request's cookie store.
Click to show internal directories.
Click to hide internal directories.