Skip to content

Commit faff955

Browse files
committed
Fix setting of SameSite on cookies
Fix go-gitea#15972 Signed-off-by: Andrew Thornton <[email protected]>
1 parent d1dbbf4 commit faff955

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

modules/web/middleware/cookie.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
149149
if len(others) > 2 {
150150
if v, ok := others[2].(string); ok && len(v) > 0 {
151151
cookie.Domain = v
152-
} else if v, ok := others[1].(func(*http.Cookie)); ok {
152+
} else if v, ok := others[2].(func(*http.Cookie)); ok {
153153
v(&cookie)
154154
}
155155
}
@@ -170,7 +170,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
170170
if len(others) > 4 {
171171
if v, ok := others[4].(bool); ok && v {
172172
cookie.HttpOnly = true
173-
} else if v, ok := others[1].(func(*http.Cookie)); ok {
173+
} else if v, ok := others[4].(func(*http.Cookie)); ok {
174174
v(&cookie)
175175
}
176176
}
@@ -179,7 +179,7 @@ func SetCookie(resp http.ResponseWriter, name string, value string, others ...in
179179
if v, ok := others[5].(time.Time); ok {
180180
cookie.Expires = v
181181
cookie.RawExpires = v.Format(time.UnixDate)
182-
} else if v, ok := others[1].(func(*http.Cookie)); ok {
182+
} else if v, ok := others[5].(func(*http.Cookie)); ok {
183183
v(&cookie)
184184
}
185185
}

0 commit comments

Comments
 (0)