Am Freitag, 10. Juli 2015 01:38:52 UTC+2 schrieb Paulo Coutinho:
Hi,
My code is:
func panelLoginProcess(c *gin.Context) { token := getSHA1Hash("2132323213")
expiration := time.Now().Add(365 * 24 * time.Hour)
cookie := http.Cookie{Name: "XYZ-SESSION", Value: token, Expires: expiration}
http.SetCookie(c.Writer, &cookie) c.Redirect(http.StatusMovedPermanently, "/panel/home/index")
}
What is wrong? Thanks.
The path attribute of the cookie depends on the path your panelLoginProcess
was invoked which might be /foo/bar/waz.html resulting in a path attribute
of /foo/bar. So this cookie will be sent only to ULRs starting with /foo/bar/
and not your /panel/home/index.
Try setting the Path explicitly to "/".
V.