Answer the question
In order to leave comments, you need to log in
Why cookies are read through time?
Declared cookies in a global variable.
Further in one of the routes I send it to the client; and then I read it.
And in another route, I just read.
(Handling of -err errors is omitted here.)
var ck = http.Cookie {
Name: "sessID",
Value: "token_Sess",
}
func main() {
http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
http.SetCookie(w, &ck)
ck_Read, err := r.Cookie("sessID")
ck_Value := ck_Read.Value
log.Println("Значение куки _sessID_ по маршруту /login:", ck_Value)
return
})
http.HandleFunc("/contacts", func(w http.ResponseWriter, r *http.Request) {
coo, err := r.Cookie("sessID")
coo_Value := coo.Value
log.Println("Значение куки _sessID_ по маршруту /contacts:", coo_Value)
return
})
}
Answer the question
In order to leave comments, you need to log in
var ck = http.Cookie {
Name: "sessID",
Value: "token_Sess",
Path: "/",
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question