You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cookie.go
    path of file: ./repos/gitea/modules/web/middleware
    
    the code of the file until where you have to start completion: // Copyright 2020 The Macaron Authors
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package middleware

import (
	"net/http"
	"net/url"
	"strings"

	"code.gitea.io/gitea/modules/s
    
func SetSiteCookie(resp http.ResponseWriter, name, value string, maxAge int) {
	cookie := &http.Cookie{
		Name:     name,
		Value:    url.QueryEscape(value),
		MaxAge:   maxAge,
		Path:     setting.SessionConfig.CookiePath,
		Domain:   setting.SessionConfig.Domain,
		Secure:   setting.SessionConfig.Secure,
		HttpOnly: true,
		SameSite: setting.SessionConfig.SameSite,
	}
	resp.Header().Add("Set-Cookie", cookie.String())
	if maxAge < 0 {
		// There was a bug in "setting.SessionConfig.CookiePath" code, the old default value of it was empty "".
		// So we have to delete the cookie on path="" again, because some old code leaves cookies on path="".
		cookie.Path = strings.TrimSuffix(setting.SessionConfig.CookiePath, "/")
		resp.Header().Add("Set-Cookie", cookie.String())
	}
}