Two dashboards on one home server, one at port 8123 and one at port 80, can read each other’s cookies. That isn’t a bug in either app. The cookie specification, RFC 6265, says in plain words that cookies do not provide isolation by port, and the same section says they don’t isolate by scheme either. Most cookie advice is written for big public websites, where the questions are about third-party tracking and cross-site request forgery. A home lab runs into the other edge of the same rules. Both cases come down to a handful of attributes on one header, Set-Cookie, and a browser’s decision about whether a request is same-site or cross-site.
What a cookie header carries
The anatomy
A server sets a cookie with a response header such as:
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax; Max-Age=3600
The name and value come first. Everything after the first semicolon is an attribute that tells the browser where, when and how long to send the cookie back.
The attributes that matter for security
MDN’s Set-Cookie reference gives the definitions:
| Attribute | What it does |
|---|---|
Secure |
Sent only over https:, except on localhost. Insecure http: pages cannot set it. |
HttpOnly |
JavaScript cannot read it through document.cookie, though it is still sent with JavaScript-initiated requests. |
SameSite=Strict |
Sent only for requests originating from the same site that set it. |
SameSite=Lax |
Same as Strict, plus cross-site top-level navigations using safe methods such as GET. |
SameSite=None |
Sent with both same-site and cross-site requests. Requires Secure. |
Max-Age / Expires |
Lifetime. If both are set, Max-Age wins; zero or negative expires it at once. |
Partitioned |
Stored in partitioned storage, keyed to the top-level site. Requires Secure. |

Same site is not same origin
What counts as a site
MDN’s glossary defines a site by its registrable domain: an entry in the Public Suffix List plus the label just before it. So developer.mozilla.org and support.mozilla.org are the same site, because both sit under mozilla.org. The page notes that port numbers are ignored, so https://example.com:8080 and https://example.com are the same site, and that in some contexts the scheme counts too, which would make http:// and https:// versions of one domain different sites.
Why that matters
SameSite rules compare sites, not origins. A request from blog.example.com to shop.example.com is cross-origin but same-site, so even a Strict cookie travels with it. SameSite protects against other domains entirely, not against sibling subdomains under the same owner. That’s why the Public Suffix List exists: it marks domains such as shared hosting suffixes where unrelated owners sit under a common parent and must not count as one site.
The decision table
Encoding the rules in Python
The rules MDN describes fit in a small function. This is a teaching model of the documented behavior, not a browser:
def cookie_sent(samesite, cross_site, top_level, method,
age_seconds=None, lax_by_default=False):
if not cross_site:
return True
if samesite == "Strict":
return False
if samesite == "None":
return True
# Lax
if top_level and method in ("GET", "HEAD"):
return True
if lax_by_default and top_level and method == "POST" \
and age_seconds is not None and age_seconds <= 120:
return True
return FalseThe output
| Request | Strict | Lax | None |
|---|---|---|---|
| Same-site link or fetch | sent | sent | sent |
| Cross-site link click (GET) | not sent | sent | sent |
| Cross-site form POST | not sent | not sent | sent |
| Cross-site image or iframe | not sent | not sent | sent |
Cross-site fetch() POST |
not sent | not sent | sent |
The two-minute exception
MDN notes that some browsers treat a cookie with no SameSite attribute as Lax, and that when Lax is applied this way as a default, a more permissive version is used: the cookie is still included in POST requests if it was set no more than two minutes before the request. The model above includes that rule through the lax_by_default flag. In this model, a cross-site form POST within two minutes of login sends a defaulted cookie but never sends one explicitly marked SameSite=Lax. The lesson is to set SameSite explicitly rather than rely on a browser’s default.

Prefixes and lifetimes
Cookie name prefixes
A cookie whose name starts with __Secure- must be set with Secure from an HTTPS page. One starting with __Host- must also have no Domain attribute and must have Path=/, which pins it to the exact host that set it. MDN lists examples the browser rejects, including __Host-id=1; Secure without a path and __Host-id=1; Secure; Path=/; Domain=example.com with a domain. Python’s standard library can build a compliant header:
from http.cookies import SimpleCookie
c = SimpleCookie()
c["__Host-id"] = "x"
c["__Host-id"]["secure"] = True
c["__Host-id"]["path"] = "/"
c["__Host-id"]["samesite"] = "Strict"
print(c.output())
# Set-Cookie: __Host-id=x; Path=/; SameSite=Strict; SecureThe __Host- prefix is the strongest form available for a session cookie on a single host, because the browser itself enforces the rules. MDN warns that browsers without prefix support simply accept the cookie, so the prefix adds assurance only where it is supported.
The 400-day cap
The working draft that will replace RFC 6265, known as rfc6265bis, says a cookie’s expiry should not be more than 400 days (34,560,000 seconds) in the future, while letting browsers adjust the limit. The IETF datatracker lists draft 22 as the latest version, in the RFC Editor queue but not yet published as an RFC. A Max-Age of ten years written into old code is likely to be cut short by a browser that follows the draft.
How much a browser must store
RFC 6265 also sets floors for storage. Section 6.1 says general-use browsers should provide at least 4,096 bytes per cookie, counting the name, value and attributes together, at least 50 cookies per domain and at least 3,000 cookies in total. These are minimums, not maximums, and browsers are free to go higher, but an app that packs a large JSON object into a cookie can hit the 4,096-byte floor and find the cookie silently dropped. A self-hosted dashboard that stores user preferences in cookies across several services on one IP address also shares that per-domain count, since all of those services look like one host to the browser. Keeping cookies small, a short random session identifier with the real data stored on the server, avoids both problems and keeps every request lighter, since the browser sends each matching cookie with every request to that host.
The home lab catch
Ports and schemes don’t separate cookies
RFC 6265, the 2011 standard still in force, says in section 8.5 that cookies do not provide isolation by port and do not provide isolation by scheme. On a home server at 192.168.1.10, a cookie named session set by an app on port 8123 is sent to an app on port 80 at the same address, and either app can overwrite the other’s cookie if both use the same name and path. Two self-hosted tools logging each other out is a common symptom.
Ways around it
- Give each service its own hostname through local DNS or a reverse proxy, such as
ha.home.arpaandpihole.home.arpa. Different hostnames keep host-only cookies apart. Thehome.arpaname is a safe choice because RFC 8375, from May 2018, designates it for non-unique use in residential home networks, so it can’t collide with a real public domain. - Use HTTPS on the LAN wherever possible. An
http:page cannot set aSecurecookie, and only anhttps:page can use the__Host-prefix. - Where an app lets cookie names be configured, give each one a distinct name.
- Avoid setting a
Domainattribute on a parent domain unless every service under it is meant to share the cookie.
Localhost is special
MDN notes that Secure cookies are allowed over plain HTTP on localhost. That makes local development easy and means a setup that works perfectly at http://localhost:3000 can quietly lose its session cookie once the same app moves to http://192.168.1.10:3000 on the LAN.

Checking what a site actually sets
In the browser
Every major browser’s developer tools show the cookies a page has set, with columns for each attribute. Opening the network panel, reloading a page and selecting a response shows the raw Set-Cookie headers. A quick review checks that every session cookie has Secure and HttpOnly, that SameSite is set explicitly, and that lifetimes are reasonable.
A short checklist for a self-hosted app
| Check | Good answer |
|---|---|
| Session cookie over HTTPS only | Secure set |
| JavaScript can’t read the session | HttpOnly set |
| Cross-site behavior chosen deliberately | SameSite=Lax or Strict written explicitly |
| Pinned to one host | __Host- prefix, Path=/, no Domain |
| Lifetime | Max-Age well under 400 days |
| Shared server with other apps | separate hostnames or distinct cookie names |
Sources
- MDN Web Docs, “Set-Cookie”: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie
- MDN Web Docs, Glossary, “Site”: https://developer.mozilla.org/en-US/docs/Glossary/Site
- IETF, RFC 6265, “HTTP State Management Mechanism” (April 2011): https://www.rfc-editor.org/rfc/rfc6265.html
- IETF, RFC 8375, “Special-Use Domain ‘home.arpa.'” (May 2018): https://www.rfc-editor.org/rfc/rfc8375.html
- IETF Datatracker, draft-ietf-httpbis-rfc6265bis: https://datatracker.ietf.org/doc/draft-ietf-httpbis-rfc6265bis/
