Go net/http/cookiejar: an in-memory RFC 6265 cookie jar
Answer: Package cookiejar implements an in-memory RFC 6265 cookie jar.
Creating a jar
New returns a new cookie jar.
A nil Options value is equivalent to a zero Options.
PublicSuffixList provides the public suffix of a domain.
A list implementation lives in the golang org x net publicsuffix package.
How cookies are stored and returned
Those list implementations must be safe for concurrent use by many goroutines.
As an example, the public suffix of example.com is com.
Cookies returns an empty slice if the URL scheme is not HTTP or HTTPS.
Localhost is considered a secure origin regardless of protocol.
See also
Claims
- id: C1 claim: This package implements an in-memory RFC 6265 cookie jar. source: S1 evidence: "implements an in-memory RFC 6265"
- id: C2 claim: New returns a new cookie jar. source: S1 evidence: "New returns a new cookie jar"
- id: C3 claim: PublicSuffixList provides the public suffix of a domain. source: S1 evidence: "PublicSuffixList provides the public suffix of a domain"
- id: C4 claim: Localhost is considered a secure origin regardless of protocol. source: S2 evidence: "Localhost is considered a secure origin"
Sources
- [S1] cookiejar package reference. The Go Authors. https://pkg.go.dev/net/http/cookiejar . License: BSD-3-Clause. Accessed 2026-11-24.
- [S2] cookiejar jar.go source. The Go Authors. https://go.dev/src/net/http/cookiejar/jar.go . License: BSD-3-Clause. Accessed 2026-11-24.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, cookiejar package reference; The Go Authors, cookiejar jar.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, cookiejar package reference; The Go Authors, cookiejar jar.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go net/http/cookiejar: an in-memory RFC 6265 cookie jar." iinventedlight Library, iil:note:swqjnxvy, version of 2026-11-24. https://iinventedlight.com/library/notes/go-cookiejar/. License: CC-BY-4.0.
@misc{iil_note_swqjnxvy,
author = {{iinventedlight}},
title = {{Go net/http/cookiejar: an in-memory RFC 6265 cookie jar}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-24},
url = {https://iinventedlight.com/library/notes/go-cookiejar/},
note = {Permanent ID iil:note:swqjnxvy. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-cookiejar.schema.json (schema; CC-BY-4.0)
- go-cookiejar.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-cookiejar.md.