cookie := &http.Cookie{Name: "username", Value: "john"} cookieString := cookie.String()
req, err := http.NewRequest("GET", "/login", nil) cookie, err := req.Cookie("username") cookieString := cookie.String()
cookie := &http.Cookie{Name: "username", Value: "john"} http.SetCookie(w, cookie)This example sets a cookie with name "username" and value "john" in an HTTP response object. The `http.SetCookie()` method is used to set the cookie. Overall, the 'net/http' package library in Go provides intuitive and efficient ways to handle HTTP cookies as strings.