Standard library / net/http
http.Cookie.String()
Serialize a cookie as a header field value. An invalid name produces an empty string; use Valid to check input. Expected stdout: 'demo=yes; Path=/; HttpOnly\n'.
Formal Syntax & Structure
go syntaxgo
func (c *Cookie) String() stringReturn Value
string
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/http")
func main() { c := http.Cookie{Name: "demo", Value: "yes", Path: "/", HttpOnly: true} fmt.Println(c.String())}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}