diff --git a/handlers/auth.go b/handlers/auth.go index 8bd99f8b21..d656a9b481 100644 --- a/handlers/auth.go +++ b/handlers/auth.go @@ -183,6 +183,19 @@ func Login(w http.ResponseWriter, r *http.Request) { RedirectData: redirectData} data.Meta.NoTrack = true + if utils.Config.Frontend.SessionCookieDeriveDomainFromRequest { + // delete old cookie + c := &http.Cookie{ + Name: utils.SessionStore.SCS.Cookie.Name, + Value: "", + Path: "/", + Expires: time.Unix(0, 0), + Domain: utils.SessionStore.SCS.Cookie.Domain, + HttpOnly: true, + } + http.SetCookie(w, c) + } + if handleTemplateError(w, r, "auth.go", "Login", "", loginTemplate.ExecuteTemplate(w, "layout", data)) != nil { return // an error has occurred and was processed }