I wrote these http cookie functions in Go as a part of a http handler that will respond to ajax calls.
cookie = &http.Cookie{
Name: "sessionId",
Value: "",
}
http.SetCookie(w, cookie)
However, I need to set my writer header to JSON as the ajax caller expects JSON response
jsonResponse, _ := json.Marshal(responseMessage) //responseMessage is a struct
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, "%s", jsonResponse)
The cookie is not set to the browser. Everything is on the same domain (no CORS). How can I send JSON with cookie data to an ajax caller together in Go?