← All notes

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

Sources

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

Permanent ID: iil:note:swqjnxvy

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.},
}

Markdown

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.

All artifact files (JSON index)

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.