File: cookie.go

package info (click to toggle)
golang-github-coreos-pkg 4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, bookworm-proposed-updates, bullseye
  • size: 328 kB
  • sloc: sh: 30; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 404 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package httputil

import (
	"net/http"
	"time"
)

// DeleteCookies effectively deletes all named cookies
// by wiping all data and setting to expire immediately.
func DeleteCookies(w http.ResponseWriter, cookieNames ...string) {
	for _, n := range cookieNames {
		c := &http.Cookie{
			Name:    n,
			Value:   "",
			Path:    "/",
			MaxAge:  -1,
			Expires: time.Time{},
		}
		http.SetCookie(w, c)
	}
}