http.SetCookie(w, &http.Cookie{ Name: "my_cookie", Value: "hello world", })
cookie, err := r.Cookie("my_cookie") if err != nil { // handle error } value := cookie.ValueThis example shows how to retrieve a cookie named "my_cookie" from an incoming HTTP request using the `r.Cookie` method. If the cookie does not exist, an error will be returned. Once the cookie is retrieved, we can access its value using the `Value` field. In both examples, we are using the net/http package in Go to work with cookies. Overall, the net/http package provides a comprehensive set of functions and methods for working with cookies in Go. By using this package, it's easy to set, retrieve, and modify cookies in your Go web applications.