func (m *MemStore) Save(r *http.Request, w http.ResponseWriter, s *sessions.Session) error {
	var cookieValue string
	if s.Options.MaxAge < 0 {
		cookieValue = ""
		m.cache.delete(s.ID)
		for k := range s.Values {
			delete(s.Values, k)
		}
	} else {
		if s.ID == "" {
			s.ID = strings.TrimRight(base32.StdEncoding.EncodeToString(securecookie.GenerateRandomKey(32)), "=")
		}
		encrypted, err := securecookie.EncodeMulti(s.Name(), s.ID, m.Codecs...)
		if err != nil {
			return err
		}
		cookieValue = encrypted
		m.cache.setValue(s.ID, m.copy(s.Values))
	}
	http.SetCookie(w, sessions.NewCookie(s.Name(), cookieValue, s.Options))
	return nil
}
Save adds a single session to the response.
Set Options.MaxAge to -1 or call MaxAge(-1) before saving the session to delete all values in it.
package memstore
import (
	"bytes"
	"encoding/base32"
	"encoding/gob"
	"fmt"
	"net/http"
	"strings"
	"github.com/gorilla/securecookie"
	"github.com/gorilla/sessions"
)
type MemStore struct {
	Codecs  []securecookie.Codec
	Options *sessions.Options
	cache   *cache
}
type valueType map[interface{}]interface{}
func NewMemStore(keyPairs ...[]byte) *MemStore {
	store := MemStore{
		Codecs: securecookie.CodecsFromPairs(keyPairs...),
		Options: &sessions.Options{
			Path:   "/",
			MaxAge: 86400 * 30,
		},
		cache: newCache(),
	}
	store.MaxAge(store.Options.MaxAge)
	return &store
}
func (m *MemStore) Get(r *http.Request, name string) (*sessions.Session, error) {
	return sessions.GetRegistry(r).Get(m, name)
}
func (m *MemStore) New(r *http.Request, name string) (*sessions.Session, error) {
	session := sessions.NewSession(m, name)
	options := *m.Options
	session.Options = &options
	session.IsNew = true
	c, err := r.Cookie(name)
	if err != nil {
		return session, nil
	}
	err = securecookie.DecodeMulti(name, c.Value, &session.ID, m.Codecs...)
	if err != nil {
		return session, err
	}
	v, ok := m.cache.value(session.ID)
	if !ok {
		return session, nil
	}
	session.Values = m.copy(v)
	session.IsNew = false
	return session, nil
}