set absolute path for Cookie in Go

123 Views Asked by At

I set cookie on requests coming at test.mysite.com, the problem is the Path parameter on the cookie is set to /test instead of plain / and this is causing issues with recognizing the cookie on different parts of the website. How can I set a cookie with absolute path, instead of a relative one?

code:

    cookie := http.Cookie{
        Name:     "session",
        Value:    "random_token",
        MaxAge:   300,
        HttpOnly: true,
        Secure:   true,
        Path:     "/",
        SameSite: http.SameSiteNoneMode,
    }

cookie:

session="random_token"; Max-Age=300; Path=/test; Secure; HttpOnly; SameSite=None; Domain=mysite.com
0

There are 0 best solutions below