I'm creating a session, after the session/cookie is created it vanishes immediately
session, err := r.Cookie("session-id")
if err != nil {
session = &http.Cookie{
Name: "session-id",
Value: sessionID.String(), //uuid
MaxAge: 0,
}
http.SetCookie(w, session)
}
I'm not sure if it's being deleted, but the moment the cookie is created it vanishes immediately from google chrome(Application/cookies). This is a problem because I can't detect the cookie when going to another path.
This is a problem because I can't detect the cookie when going to another path.
If the path parameter is not set in the set cookie response header, then the client sets the cookie's path to the request path. Clients only send a cookie to the server when the cookie's path is a path prefix of the request path.
To make a cookie available to all paths, set the path to "/".
session = &http.Cookie{
Name: "session-id",
Value: sessionID.String(), //uuid
Path: "/",
}
(Because the zero value for an integer is 0, there's no need to specify the MaxAge value).