diff --git a/server/utils/cookie.go b/server/utils/cookie.go index 16cddb5..a37f187 100644 --- a/server/utils/cookie.go +++ b/server/utils/cookie.go @@ -10,10 +10,15 @@ import ( func SetCookie(gc *gin.Context, token string) { secure := true httpOnly := true - host := GetDomainName(constants.AUTHORIZER_URL) + host := GetHostName(constants.AUTHORIZER_URL) + domain := GetDomainName(constants.AUTHORIZER_URL) + if domain != "localhost" { + domain = "." + domain + } gc.SetSameSite(http.SameSiteNoneMode) gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", host, secure, httpOnly) + gc.SetCookie(constants.COOKIE_NAME+"-client", token, 3600, "/", domain, secure, httpOnly) } func GetCookie(gc *gin.Context) (string, error) { @@ -30,7 +35,12 @@ func DeleteCookie(gc *gin.Context) { httpOnly := true host := GetDomainName(constants.AUTHORIZER_URL) + domain := GetDomainName(constants.AUTHORIZER_URL) + if domain != "localhost" { + domain = "." + domain + } gc.SetSameSite(http.SameSiteNoneMode) gc.SetCookie(constants.COOKIE_NAME, "", -1, "/", host, secure, httpOnly) + gc.SetCookie(constants.COOKIE_NAME+"-client", "", -1, "/", domain, secure, httpOnly) }