Documentation
¶
Index ¶
- func DecodeCookie(hashKey, aesKey []byte, name string, value string, dst interface{}) error
- func EncodeCookie(hashKey, aesKey []byte, name string, value interface{}) (string, error)
- func NewCookie(name, value string, options *Options) *http.Cookie
- type CookieStore
- type Options
- type Session
- type Sessions
- type Store
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeCookie ¶
decode decodes a cookie value
It decodes, verifies a message authentication code, and finally deserializes the value.
The name argument is the cookie name. It must be the same name used when it was stored.
The value argument is the encoded cookie value. The dst argument is where the cookie will be decoded. It must be a pointer.
func EncodeCookie ¶
encode encodes a cookie value.
It serializes, optionally encrypts, signs with a message authentication code, and finally encodes the value.
The name argument is the cookie name. It is stored with the encoded value. The value argument is the value to be encoded. It can be any value that can be encoded using the currently selected serializer
It is the client's responsibility to ensure that value, when encoded using the current serialization/encryption settings on s and then base64-encoded, is shorter than the maximum permissible length.
Types ¶
type CookieStore ¶
type CookieStore struct {
// contains filtered or unexported fields
}
func NewCookieStore ¶
func NewCookieStore(secret, aesKey string) *CookieStore
func (*CookieStore) New ¶
func (store *CookieStore) New(sid, name string) *Session
func (*CookieStore) Save ¶
func (store *CookieStore) Save(rw http.ResponseWriter, req *http.Request, session *Session) error
type Session ¶
type Session struct { Name string Values Values Id string Options *Options // contains filtered or unexported fields }
func NewSession ¶
type Sessions ¶
type Sessions struct { // Store use to store session, it can be any store that implement the Store interface. Store Store // contains filtered or unexported fields }
Sessions is a global session manager
func NewSessions ¶
NewSessions create a global sessions manager, default store is Cookie store.
secret used to sign the cookie value.
The aesKey argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256, if aesKey is empty string, the cookie value will not Encrypted.