Repository: gofiber/fiber
File: res.go (Go)

Code before:
// If no key is provided it expires all cookies that came with the request.
//
// Note: This method does not work for cookies with a specific Domain or Path.
// For those cases, use ExpireCookie to specify the matching attributes.
func (r *DefaultRes) ClearCookie(key ...string) {
	request := &r.c.fasthttp.Request
	response := &r.c.fasthttp.Response
	if len(key) > 0 {
		for i := range key {
			response.Header.DelClientCookie(key[i])
		}
		return
	}
	for k := range request.Header.Cookies() {
		response.Header.DelClientCookieBytes(k)
	}
}

// ExpireCookie expires a cookie by its cookie definition.
// This is useful when you need to expire a cookie that was set with a specific
// Path or Domain. The browser will only clear the cookie if the Path and Domain
// attributes match the original cookie.
//
// Only the Name, Path, Domain, Secure, HTTPOnly, SameSite, and Partitioned fields are used.
// The Value and Expires fields are overwritten to expire the cookie.
func (r *DefaultRes) ExpireCookie(cookie *Cookie) {
	fcookie := fasthttp.AcquireCookie()
	defer fasthttp.ReleaseCookie(fcookie)

	fcookie.SetKey(cookie.Name)
	fcookie.SetValue("")
	fcookie.SetExpire(fasthttp.CookieExpireDelete)

	if cookie.Path != "" {
		fcookie.SetPath(cookie.Path)
	}
	if cookie.Domain != "" {
		fcookie.SetDomain(cookie.Domain)
	}

	// Handle SameSite attribute
	isSecure := cookie.Secure
	switch {
	case utils.EqualFold(cookie.SameSite, CookieSameSiteStrictMode):
		fcookie.SetSameSite(fasthttp.CookieSameSiteStrictMode)
	case utils.EqualFold(cookie.SameSite, CookieSameSiteNoneMode):
		fcookie.SetSameSite(fasthttp.CookieSameSiteNoneMode)
		isSecure = true // SameSite=None requires Secure
	case utils.EqualFold(cookie.SameSite, CookieSameSiteLaxMode):
		fcookie.SetSameSite(fasthttp.CookieSameSiteLaxMode)
	default:

Review comment (suggestion):
```go
cookie.Expires = fasthttp.CookieExpireDelete
cookie.Value = "" // not really needed

c.Res().Cookie(cookie)
```
@darwin808 
Do the same thing or?

I'm not sure if that justifies a completely new function.

Code after:
// If no key is provided it expires all cookies that came with the request.
func (r *DefaultRes) ClearCookie(key ...string) {
	request := &r.c.fasthttp.Request
	response := &r.c.fasthttp.Response
	if len(key) > 0 {
		for i := range key {
			response.Header.DelClientCookie(key[i])
		}
		return
	}
	for k := range request.Header.Cookies() {
		response.Header.DelClientCookieBytes(k)
	}
}

// RequestCtx returns *fasthttp.RequestCtx that carries a deadline
// a cancellation signal, and other values across API boundaries.
func (r *DefaultRes) RequestCtx() *fasthttp.RequestCtx {
	return r.c.fasthttp
}

// Cookie sets a cookie by passing a cookie struct.
func (r *DefaultRes) Cookie(cookie *Cookie) {
	if cookie.Path == "" {
		cookie.Path = "/"
	}

	if cookie.SessionOnly {
		cookie.MaxAge = 0
		cookie.Expires = time.Time{}
	}

	var sameSite http.SameSite

	switch {
	case utils.EqualFold(cookie.SameSite, CookieSameSiteStrictMode):
		sameSite = http.SameSiteStrictMode
	case utils.EqualFold(cookie.SameSite, CookieSameSiteNoneMode):
		sameSite = http.SameSiteNoneMode
		// SameSite=None requires Secure=true per RFC and browser requirements
		cookie.Secure = true
	case utils.EqualFold(cookie.SameSite, CookieSameSiteDisabled):
		sameSite = 0
	case utils.EqualFold(cookie.SameSite, CookieSameSiteLaxMode):
		sameSite = http.SameSiteLaxMode
	default:
		sameSite = http.SameSiteLaxMode
	}

	// Partitioned requires Secure=true per CHIPS spec
	if cookie.Partitioned {