Skip to content

Instantly share code, notes, and snippets.

@yeknava
Last active December 27, 2021 00:22
Show Gist options
  • Select an option

  • Save yeknava/cde608416899a9070155 to your computer and use it in GitHub Desktop.

Select an option

Save yeknava/cde608416899a9070155 to your computer and use it in GitHub Desktop.
Golang get cookie by name
func getCookieByName(cookie []*http.Cookie, name string) string {
cookieLen := len(cookie)
result := ""
for i := 0; i < cookieLen; i++ {
if cookie[i].Name == name {
result = cookie[i].Value
}
}
return result
}
@veilm
Copy link

veilm commented Dec 27, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment