Get decodes the cookie into the value. Returns false if the cookie is not there.
(w http.ResponseWriter, r *http.Request, v any)
| 69 | |
| 70 | // Get decodes the cookie into the value. Returns false if the cookie is not there. |
| 71 | func (d *Cookie) Get(w http.ResponseWriter, r *http.Request, v any) (bool, error) { |
| 72 | s, err := webmiddleware.GetSecureCookie(r.Context()) |
| 73 | if err != nil { |
| 74 | return false, err |
| 75 | } |
| 76 | |
| 77 | cookie, err := r.Cookie(d.Name) |
| 78 | if err != nil || cookie.Value == tombstone { |
| 79 | return false, nil |
| 80 | } |
| 81 | |
| 82 | err = s.Decode(d.Name, cookie.Value, v) |
| 83 | if err != nil { |
| 84 | d.Remove(w, r) |
| 85 | return false, nil |
| 86 | } |
| 87 | |
| 88 | return true, nil |
| 89 | } |
| 90 | |
| 91 | // Set the value of the cookie. |
| 92 | func (d *Cookie) Set(w http.ResponseWriter, r *http.Request, v any) error { |
nothing calls this directly
no test coverage detected