From 2ea9df0aba0f842e4cfae724498404940cb72857 Mon Sep 17 00:00:00 2001 From: "Sharl.Jimh.Tsin" Date: Tue, 11 Apr 2023 13:50:20 +0800 Subject: [PATCH] fix cookies not match while using subPath (#51) --- results/stats.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/results/stats.go b/results/stats.go index 8e2b600..0f797d7 100644 --- a/results/stats.go +++ b/results/stats.go @@ -23,11 +23,12 @@ type StatsData struct { var ( key = []byte(securecookie.GenerateRandomKey(32)) store = sessions.NewCookieStore(key) + conf = config.LoadedConfig() ) func init() { store.Options = &sessions.Options{ - Path: "/stats", + Path: conf.BaseURL+"/stats", MaxAge: 3600 * 1, // 1 hour HttpOnly: true, SameSite: http.SameSiteStrictMode, @@ -43,8 +44,6 @@ func Stats(w http.ResponseWriter, r *http.Request) { return } - conf := config.LoadedConfig() - if conf.DatabaseType == "none" { render.PlainText(w, r, "Statistics are disabled") return