Documentation
¶
Index ¶
- Variables
- func Lock(sess *sessions.Session)
- func RLock(sess *sessions.Session)
- func RUnlock(sess *sessions.Session)
- func Unlock(sess *sessions.Session)
- type Store
- func (s *Store) Clean(inactive time.Duration) error
- func (s *Store) Delete(sess *sessions.Session) error
- func (s *Store) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *Store) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *Store) Save(r *http.Request, w http.ResponseWriter, sess *sessions.Session) error
- func (s *Store) SetKeys(hash, block []byte)
Constants ¶
This section is empty.
Variables ¶
var ( SessionLastUpdated = "__sess_last_updated" CookieIdName = "sess_sessionid" SqlTableName = "sess_session" SqlCreateSession = ` CREATE TABLE IF NOT EXISTS ` + SqlTableName + ` ( id BYTEA NOT NULL, name VARCHAR (255) NOT NULL, key TEXT NOT NULL, value TEXT NOT NULL, PRIMARY KEY (id, name, key) ) ` )
Functions ¶
Types ¶
type Store ¶
func (*Store) SetKeys ¶
SetKeys sets the hash and block keys used to read and write the session cookie. A hash key is required and is used to to authenticate a cookie value using HMAC. It's recommend to be 32 or 64 bytes.
A block key is optional and is used to encrypt the cookie value. If it's set to nil, then encryption will not be used. This package uses AES, so the block key must have length 16, 24 or 32 bytes corresponding to AES-128, AES-192 or AES-256. If the block key violates these constraints, SetKeys will panic.
This method is exposed so that multiple instantiations of session stores can share the same cookie. This particularly useful if you want to be able to restart your web server without invalidating existing user sessions.
If this method is not called, then a fresh set of keys is created automatically, but will invalidate all existing user sessions.