func (d *Cookie) Set(w http.ResponseWriter, r *http.Request, v interface{}) error {
	s, err := webmiddleware.GetSecureCookie(r.Context())
	if err != nil {
		return err
	}
	str, err := s.Encode(d.Name, v)
	if err != nil {
		return err
	}
	c := d.new(r)
	c.Value = str
	http.SetCookie(w, &c)
	return nil
}
Set the value of the cookie.
package cookie
import (
	"net/http"
	"time"
	"go.thethings.network/lorawan-stack/v3/pkg/webmiddleware"
)
const (
	tombstone = "<deleted>"
)
type Cookie struct {
	Name string
	Path string
	MaxAge time.Duration
	HTTPOnly bool
	SameSite http.SameSite
}
func (d *Cookie) new(r *http.Request) http.Cookie {
	sameSite := d.SameSite
	if sameSite == 0 {
		sameSite = http.SameSiteLaxMode
	}
	return http.Cookie{
		Name:     d.Name,
		Path:     d.Path,
		MaxAge:   int(d.MaxAge.Nanoseconds() / 1000),
		Secure:   r.URL.Scheme == "https",
		HttpOnly: d.HTTPOnly,
		SameSite: sameSite,
	}
}
func (d *Cookie) Get(w http.ResponseWriter, r *http.Request, v interface{}) (bool, error) {
	s, err := webmiddleware.GetSecureCookie(r.Context())
	if err != nil {
		return false, err
	}
	cookie, err := r.Cookie(d.Name)
	if err != nil || cookie.Value == tombstone {
		return false, nil
	}
	err = s.Decode(d.Name, cookie.Value, v)
	if err != nil {
		d.Remove(w, r)
		return false, nil
	}
	return true, nil
}