Documentation
¶
Overview ¶
Package cookie parses and serializes HTTP cookie headers.
It is a port of the npm package "cookie". Parse reads a "Cookie" request header into a map, URL-decoding values. Serialize produces a "Set-Cookie" header value with the given attributes, URL-encoding the value.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses a Cookie header (for example "a=1; b=2") into a map of names to values. Values are URL-decoded. When a name appears more than once, the first occurrence wins.
Types ¶
type Options ¶
type Options struct {
// Path sets the Path attribute.
Path string
// Domain sets the Domain attribute.
Domain string
// Expires sets the Expires attribute. A zero time omits the attribute.
Expires time.Time
// MaxAge sets the Max-Age attribute. Following net/http conventions:
// a positive value sets Max-Age to that number of seconds, a negative
// value sets Max-Age=0 (delete now), and zero omits the attribute.
MaxAge int
// Secure sets the Secure attribute.
Secure bool
// HttpOnly sets the HttpOnly attribute.
HttpOnly bool
// SameSite sets the SameSite attribute; recognized values are "Lax",
// "Strict", and "None" (case-insensitive). An empty value omits it.
SameSite string
}
Options holds the attributes used when serializing a cookie.
Click to show internal directories.
Click to hide internal directories.