I want to set cookie in Go:
func rememberMe(w http.ResponseWriter,username string) {
expiration := time.Now().AddDate(0,1,0) // cookie will be stored for 1 month
cookie := http.Cookie{Name: "rememberMe",Value: username,Expires: expiration}
http.SetCookie(w,&cookie)
fmt.Println("Cookie has been set.")
}
The response was quite fine and there was a Set-Cookie filed:
Access-Control-Allow-Headers: Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin: *
Content-Length: 10
Content-Type: text/plain; charset=utf-8
Date: Thu, 20 Sep 2018 12:48:20 GMT
Set-Cookie: rememberMe=buddy; Expires=Sat, 20 Oct 2018 12:48:19 GMT
But when I used Chrome developer tools to check the cookie, there was no cookie. I am confused about this problem.