Update output.go

add SameSite for Cookie
This commit is contained in:
xjl662750 2021-06-29 09:31:50 +08:00 committed by GitHub
parent 61f5ce8c6c
commit 4fa797feaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,6 +154,13 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface
fmt.Fprintf(&b, "; HttpOnly")
}
}
// default empty
if len(others) > 5 {
if v, ok := others[5].(string); ok && len(v) > 0 {
fmt.Fprintf(&b, "; SameSite=%s", sanitizeValue(v))
}
}
output.Context.ResponseWriter.Header().Add("Set-Cookie", b.String())
}