func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error {
	if session.Options.MaxAge <= 0 {
		if err := s.delete(r.Context(), session); err != nil {
			return err
		}
		http.SetCookie(w, sessions.NewCookie(session.Name(), "", session.Options))
		return nil
	}
	if session.ID == "" {
		id, err := s.keyGen()
		if err != nil {
			return errors.New("redisstore: failed to generate session id")
		}
		session.ID = id
	}
	if err := s.save(r.Context(), session); err != nil {
		return err
	}
	http.SetCookie(w, sessions.NewCookie(session.Name(), session.ID, session.Options))
	return nil
}
Save adds a single session to the response.

If the Options.MaxAge of the session is <= 0 then the session file will be
deleted from the store. With this process it enforces the properly
session cookie handling so no need to trust in the cookie management in the
web browser.
package redisstore
import (
	"bytes"
	"context"
	"crypto/rand"
	"encoding/base32"
	"encoding/gob"
	"errors"
	"github.com/go-redis/redis/v8"
	"github.com/gorilla/sessions"
	"io"
	"net/http"
	"strings"
	"time"
)
type RedisStore struct {
	client redis.UniversalClient
	options sessions.Options
	keyPrefix string
	keyGen KeyGenFunc
	serializer SessionSerializer
}
type KeyGenFunc func() (string, error)
func NewRedisStore(ctx context.Context, client redis.UniversalClient) (*RedisStore, error) {
	rs := &RedisStore{
		options: sessions.Options{
			Path:   "/",
			MaxAge: 86400 * 30,
		},
		client:     client,
		keyPrefix:  "session:",
		keyGen:     generateRandomKey,
		serializer: GobSerializer{},
	}
	return rs, rs.client.Ping(ctx).Err()
}
func (s *RedisStore) Get(r *http.Request, name string) (*sessions.Session, error) {
	return sessions.GetRegistry(r).Get(s, name)
}
func (s *RedisStore) New(r *http.Request, name string) (*sessions.Session, error) {
	session := sessions.NewSession(s, name)
	opts := s.options
	session.Options = &opts
	session.IsNew = true
	c, err := r.Cookie(name)
	if err != nil {
		return session, nil
	}
	session.ID = c.Value
	err = s.load(r.Context(), session)
	if err == nil {
		session.IsNew = false
	} else if err == redis.Nil {
		err = nil  
	}
	return session, err
}