aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-06-11 11:31:23 +0800
committerGitHub <noreply@github.com>2024-06-11 11:31:23 +0800
commit5342a61124bf2d4fbe4c1d560b13866198149ac9 (patch)
tree77d41fcacbcace7057e47af7c7ba3dc7fe0c9c3f /modules
parent1844dc6c1d4d40e2b7f493d56b5f4e371a835e38 (diff)
downloadgitea-5342a61124bf2d4fbe4c1d560b13866198149ac9.tar.gz
gitea-5342a61124bf2d4fbe4c1d560b13866198149ac9.zip
Delete legacy cookie before setting new cookie (#31306)
Try to fix #31202
Diffstat (limited to 'modules')
-rw-r--r--modules/web/middleware/cookie.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/web/middleware/cookie.go b/modules/web/middleware/cookie.go
index ec6b06f993..f2d25f5b1c 100644
--- a/modules/web/middleware/cookie.go
+++ b/modules/web/middleware/cookie.go
@@ -35,6 +35,10 @@ func GetSiteCookie(req *http.Request, name string) string {
// SetSiteCookie returns given cookie value from request header.
func SetSiteCookie(resp http.ResponseWriter, name, value string, maxAge int) {
+ // Previous versions would use a cookie path with a trailing /.
+ // These are more specific than cookies without a trailing /, so
+ // we need to delete these if they exist.
+ deleteLegacySiteCookie(resp, name)
cookie := &http.Cookie{
Name: name,
Value: url.QueryEscape(value),
@@ -46,10 +50,6 @@ func SetSiteCookie(resp http.ResponseWriter, name, value string, maxAge int) {
SameSite: setting.SessionConfig.SameSite,
}
resp.Header().Add("Set-Cookie", cookie.String())
- // Previous versions would use a cookie path with a trailing /.
- // These are more specific than cookies without a trailing /, so
- // we need to delete these if they exist.
- deleteLegacySiteCookie(resp, name)
}
// deleteLegacySiteCookie deletes the cookie with the given name at the cookie