Documentation ¶
Index ¶
- Constants
- Variables
- type CascadeStore
- func (cs *CascadeStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (cs *CascadeStore) New(r *http.Request, name string) (session *sessions.Session, err error)
- func (cs *CascadeStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) (err error)
- func (cs *CascadeStore) SetKeyPrefix(p string)
- func (cs *CascadeStore) SetMaxAge(v int)
- func (cs *CascadeStore) SetMaxLength(l int)
- func (cs *CascadeStore) SetSerializer(ss SessionSerializer)
- type GobSerializer
- type JSONSerializer
- type SessionSerializer
Constants ¶
const ( CkDoDisplayLogging = "SessionCascadeDisplayLogging" CkMaxMemcacheSessionSizeBytes = "MaxMemcacheSessionSizeBytes" )
Config keys
const ( RequestBackend = 1 << iota MemcacheBackend = 1 << iota DatastoreBackend = 1 << iota )
const ( // In most cases we won't want to use the "request" backend. Though it's // nice to prevent hitting Memcache or Datastore if the information is // requested multiple times during a single request, it won't be updated by // concurrent requests from the same user/browser. The distributed backends // will receive the updates but the "Request" backend will preempt it with // potentially old information. We'd have to implement a secondary channel, // like the Channel API, to receive fault notifications from other requests // that do an update so that we can know to update the information in the // request. DistributedBackends = MemcacheBackend | DatastoreBackend AllBackends = RequestBackend | MemcacheBackend | DatastoreBackend // Amount of time for cookies/redis keys to expire. DefaultExpireSeconds = 86400 * 30 MaxValueLength = 4096 DefaultMaxAgeSeconds = 60 * 20 DefaultKeyPrefix = "session." )
Variables ¶
var (
ErrValueTooBig = e.New("the value to store for the session is too big")
)
Errors
Functions ¶
This section is empty.
Types ¶
type CascadeStore ¶
type CascadeStore struct { Codecs []securecookie.Codec Options *sessions.Options // default configuration DefaultMaxAge int // default Redis TTL for a MaxAge == 0 session // contains filtered or unexported fields }
func NewCascadeStore ¶
func NewCascadeStore(backendTypes int, keyPairs ...[]byte) *CascadeStore
func (*CascadeStore) Get ¶
Get returns a session for the given name after adding it to the registry.
See gorilla/sessions FilesystemStore.Get().
func (*CascadeStore) New ¶
New returns a session for the given name without adding it to the registry.
See gorilla/sessions FilesystemStore.New().
func (*CascadeStore) Save ¶
func (cs *CascadeStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) (err error)
Save adds a single session to the response.
func (*CascadeStore) SetKeyPrefix ¶
func (cs *CascadeStore) SetKeyPrefix(p string)
SetKeyPrefix set the prefix
func (*CascadeStore) SetMaxAge ¶
func (cs *CascadeStore) SetMaxAge(v int)
SetMaxAge restricts the maximum age, in seconds, of the session record both in database and a browser. This is to change session storage configuration. If you want just to remove session use your session `s` object and change it's `Options.MaxAge` to -1, as specified in
http://godoc.org/github.com/gorilla/sessions#Options
Default is the one provided by this package value - `DefaultExpireSeconds`. Set it to 0 for no restriction. Because we use `MaxAge` also in SecureCookie crypting algorithm you should use this function to change `MaxAge` value.
func (*CascadeStore) SetMaxLength ¶
func (cs *CascadeStore) SetMaxLength(l int)
SetMaxLength sets RediStore.maxLength if the `l` argument is greater or equal 0 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 RediStore is 4096. Redis allows for max. value sizes of up to 512MB (http://redis.io/topics/data-types) Default: 4096,
func (*CascadeStore) SetSerializer ¶
func (cs *CascadeStore) SetSerializer(ss SessionSerializer)
SetSerializer sets the serializer
type GobSerializer ¶
type GobSerializer struct{}
GobSerializer uses gob package to encode the session map
func (GobSerializer) Deserialize ¶
func (s GobSerializer) Deserialize(d []byte, ss *sessions.Session) error
Deserialize back to map[interface{}]interface{}
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{}