Set the value of the cookie.
(w http.ResponseWriter, r *http.Request, v any)
| 90 | |
| 91 | // Set the value of the cookie. |
| 92 | func (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. |
| 111 | func (d *Cookie) Exists(r *http.Request) bool { |
nothing calls this directly
no test coverage detected