http.SetCookie(w, &http.Cookie{ Name: "username", Value: "john", Path: "/", })
http.SetCookie(w, &http.Cookie{ Name: "mycookie", Value: "secret", Path: "/user", })In this second code example, we’re setting the cookie Path to /user, which restricts the cookie to all URLs beginning with /user. Package library: net/http