cookie.go 404 B

123456789101112131415161718192021
  1. package httputil
  2. import (
  3. "net/http"
  4. "time"
  5. )
  6. // DeleteCookies effectively deletes all named cookies
  7. // by wiping all data and setting to expire immediately.
  8. func DeleteCookies(w http.ResponseWriter, cookieNames ...string) {
  9. for _, n := range cookieNames {
  10. c := &http.Cookie{
  11. Name: n,
  12. Value: "",
  13. Path: "/",
  14. MaxAge: -1,
  15. Expires: time.Time{},
  16. }
  17. http.SetCookie(w, c)
  18. }
  19. }