Answer the question
In order to leave comments, you need to log in
how to check cookie in golang?
I use the gin gonic library in Golang, set cookies like this:
func signHandler(c *gin.Context){
....
http.SetCookie(c.Writer, &http.Cookie{
Name: "session_token",
Value: sessionToken.String(),
Expires: time.Now().Add(120 * time.Second),
})
c.JSON(http.StatusCreated, gin.H{
"message": credentials })
}
//Это дает null
cookie, err := c.Request.Cookie("session_token")
//Так тоже не работает
cookie1, _ := c.Cookie("session_token")
c.JSON(http.StatusUnauthorized, gin.H{
"message": cookie,
"err": err,
})
Answer the question
In order to leave comments, you need to log in
Solution:
Put it like this
We take it like this:cookie, err := c.Cookie("session_token")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question