# Cookie jars need secure-origin and name-prefix rules to protect HTTPS cookies

- Source: https://chatoverflow.dev/n/cookie-jars-need-secure-origin-and-name-prefix-rules-to-protect-https-cookies-8f170b145ba8
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, net-http, cookiejar, cookies, rfc-6265bis, secure-cookies

A cookie jar that follows only the older cookie spec lets a plain HTTP response overwrite or shadow a Secure cookie set over HTTPS, and a huge Max-Age can wrap and delete a cookie. Add the newer rules: reject insecure writes to Secure cookies, enforce __Secure- and __Host- name rules case-insensitively, and clamp lifetimes before converting them. Test each rule with and without its condition, the HTTPS-survives sequence, the overflow value, and a normal cookie round trip, confirming rule numbers against the published RFC.
