{"id":37878666,"url":"https://github.com/go-http-utils/cookie","last_synced_at":"2026-01-16T16:46:49.644Z","repository":{"id":57481127,"uuid":"78706360","full_name":"go-http-utils/cookie","owner":"go-http-utils","description":":cookie:Advanced cookie library for Go, support signed cookies.","archived":false,"fork":false,"pushed_at":"2017-11-04T13:42:15.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-19T16:33:20.914Z","etag":null,"topics":["signed-cookies"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/go-http-utils/cookie","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-http-utils.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-12T03:49:47.000Z","updated_at":"2024-06-19T16:33:20.914Z","dependencies_parsed_at":"2022-09-26T16:31:01.366Z","dependency_job_id":null,"html_url":"https://github.com/go-http-utils/cookie","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/go-http-utils/cookie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-http-utils%2Fcookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-http-utils%2Fcookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-http-utils%2Fcookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-http-utils%2Fcookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-http-utils","download_url":"https://codeload.github.com/go-http-utils/cookie/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-http-utils%2Fcookie/sbom","scorecard":{"id":431963,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-http-utils/cookie","commit":"5e5f3b789d36cf7b2814091f3fd34edac0645e1e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 1/14 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T03:35:12.374Z","repository_id":57481127,"created_at":"2025-08-19T03:35:12.374Z","updated_at":"2025-08-19T03:35:12.374Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28480081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["signed-cookies"],"created_at":"2026-01-16T16:46:48.258Z","updated_at":"2026-01-16T16:46:49.633Z","avatar_url":"https://github.com/go-http-utils.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cookie\n\nAdvanced cookie library for Go, support signed cookies.\n\n[![Build Status](https://travis-ci.org/go-http-utils/cookie.svg?branch=master)](https://travis-ci.org/go-http-utils/cookie)\n[![Coverage Status](http://img.shields.io/coveralls/go-http-utils/cookie.svg?style=flat-square)](https://coveralls.io/r/go-http-utils/cookie)\n[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/go-http-utils/cookie/master/LICENSE)\n[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/go-http-utils/cookie)\n\n## Features\n\n1. **Lazy**: Since cookie verification against multiple keys could be expensive, cookies are only verified lazily when accessed, not eagerly on each request.\n1. **Convenient**: Signed cookies are stored the same way as unsigned cookies. An additional signature cookie is stored for each signed cookie, using a standard naming convention (_cookie-name_`.sig`). This allows other libraries to access the original cookies without having to know the signing mechanism.\n1. **compatibility** for https://github.com/pillarjs/cookies\n\n## API\n\n### cookie.New(w http.ResponseWriter, r *http.Request[, keys ...string])\n\nIt returns a Cookies instance with optional keygrip for signed cookies.\n\n### cookies.Set(name, val string[, opts *Options])\n\nIt set the given cookie to the response and returns the current context to allow chaining. If options omit, it will use default options.\n\n**Options:**\n\n- `MaxAge`: a number representing the milliseconds for expiry (default to `0`)\n- `Path`: a string indicating the path of the cookie (default to `\"/\"`).\n- `Domain`: a string indicating the domain of the cookie (default to `\"\"`).\n- `Secure`: a boolean indicating whether the cookie is only to be sent over HTTP(S) (default to `false`).\n- `HTTPOnly`: a boolean indicating whether the cookie is only to be sent over HTTP(S) (default to `true`).\n- `Signed`: a boolean indicating whether the cookie is to be signed (default to `false`). If this is true, another cookie of the same name with the `.sig` suffix appended will also be sent.\n\n### cookies.Get(name string[, signed bool])\n\nIt returns the cookie with the given name from the Cookie header in the request. If such a cookie exists, its value is returned. Otherwise, nothing is returned. signed = true can optionally be passed as the second parameter. In this case, a signature cookie (a cookie of same name ending with the .sig suffix appended) is fetched. If the signature cookie does exist, cookie will check the hash of cookie-value whether matches registered keys.\n\n## Example\n\n```go\npackage main\n\nimport (\n  \"net/http\"\n\n  \"github.com/go-http-utils/cookie\"\n)\n\nfunc main() {\n  http.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n    cookies := cookie.New(w, r, \"some key\")\n\n    cookies.Set(\"test\", \"some cookie\", \u0026cookie.Options{\n      Signed:   true,\n      HTTPOnly: true,\n    })\n\n    value, err := cookies.Get(\"test\", true)\n    if err != nil {\n      w.WriteHeader(500)\n      w.Write([]byte(err.Error()))\n    } else {\n      w.Write([]byte(value))\n    }\n  })\n\n  http.ListenAndServe(\":8080\", nil)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-http-utils%2Fcookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-http-utils%2Fcookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-http-utils%2Fcookie/lists"}