Code below I have tried several methods using cookie jar etc to no avail, this is the simplest example:
also tried this Go HTTP Client not returning cookies
with the same results.
if you run the code you can see only one cookie but in the browser there are several more
var url = "http://www.apple.com"
func main() {
//Create Client
client := http.Client{}
//Create Varible
// Create Request
req, _ := http.NewRequest("GET", url, nil)
resp, err := client.Do(req) //send request
if err != nil {
return
}
cookies := resp.Cookies() //save cookies
// Create New Request
resp, err = client.Do(req) //send request
if err != nil {
return
}
fmt.Println("------------------------------------------------")
for _, cookie := range cookies {
fmt.Println(cookie)
}
}