MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Set

Method Set

pkg/web/cookie/cookie.go:92–108  ·  view source on GitHub ↗

Set the value of the cookie.

(w http.ResponseWriter, r *http.Request, v any)

Source from the content-addressed store, hash-verified

90
91// Set the value of the cookie.
92func (d *Cookie) Set(w http.ResponseWriter, r *http.Request, v any) error {
93 s, err := webmiddleware.GetSecureCookie(r.Context())
94 if err != nil {
95 return err
96 }
97
98 str, err := s.Encode(d.Name, v)
99 if err != nil {
100 return err
101 }
102
103 c := d.new(r)
104 c.Value = str
105 http.SetCookie(w, &c)
106
107 return nil
108}
109
110// Exists checks if the cookies exists.
111func (d *Cookie) Exists(r *http.Request) bool {

Callers

nothing calls this directly

Calls 4

newMethod · 0.95
GetSecureCookieFunction · 0.92
ContextMethod · 0.65
EncodeMethod · 0.65

Tested by

no test coverage detected