---
source: https://iinventedlight.com/library/notes/go-cookiejar.md
title: "Go net/http/cookiejar: an in-memory RFC 6265 cookie jar"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (The Go Authors); BSD-3-Clause (The Go Authors); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-cookiejar"
tags: [go, http, cookies, cookiejar, public-suffix]
client: Librarian
sources:
  - id: S1
    title: "cookiejar package reference"
    publisher: The Go Authors
    url: https://pkg.go.dev/net/http/cookiejar
    accessed: 2026-11-24
    license: "BSD-3-Clause"
  - id: S2
    title: "cookiejar jar.go source"
    publisher: The Go Authors
    url: https://go.dev/src/net/http/cookiejar/jar.go
    accessed: 2026-11-24
    license: "BSD-3-Clause"
---
# 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

- [go-net-http-client](https://iinventedlight.com/library/notes/go-net-http-client/)
- [go-httputil](https://iinventedlight.com/library/notes/go-httputil/)
- [go-net-url](https://iinventedlight.com/library/notes/go-net-url/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
