Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sbinet/mozcookie
mozcookie reads and writes files in the Mozilla/Netscape HTTP Cookie File format
https://github.com/sbinet/mozcookie
cookies cookiestorage golang mozilla netscape-cookies
Last synced: 12 days ago
JSON representation
mozcookie reads and writes files in the Mozilla/Netscape HTTP Cookie File format
- Host: GitHub
- URL: https://github.com/sbinet/mozcookie
- Owner: sbinet
- License: bsd-3-clause
- Created: 2022-04-21T09:30:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-03T14:23:08.000Z (3 months ago)
- Last Synced: 2024-12-06T09:11:06.521Z (17 days ago)
- Topics: cookies, cookiestorage, golang, mozilla, netscape-cookies
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mozcookie
[![GitHub release](https://img.shields.io/github/release/sbinet/mozcookie.svg)](https://github.com/sbinet/mozcookie/releases)
[![GoDoc](https://pkg.go.dev/badge/github.com/sbinet/mozcookie?status.svg)](https://pkg.go.dev/github.com/sbinet/mozcookie)
[![CI](https://github.com/sbinet/mozcookie/workflows/CI/badge.svg)](https://github.com/sbinet/mozcookie/actions)
[![codecov](https://codecov.io/gh/sbinet/mozcookie/branch/main/graph/badge.svg)](https://codecov.io/gh/sbinet/mozcookie)
[![License](https://img.shields.io/badge/License-BSD--3-blue.svg)](https://github.com/sbinet/mozcookie/blob/main/LICENSE)`mozcookie` is a simple package providing tools to read and write cookies from and to files in the Netscape HTTP Cookie File format.
For more informations about this format, see:
- [http://curl.haxx.se/rfc/cookie_spec.html](http://curl.haxx.se/rfc/cookie_spec.html)
## Example
```go
cookies := []*http.Cookie{
&http.Cookie{Name: "cookie-1", Value: "v$1", Domain: "golang.org", Path: "/pkg/"},
&http.Cookie{Name: "cookie-2", Value: "v$2", Domain: "golang.org", Path: "/pkg/", Secure: true},
&http.Cookie{Name: "cookie-3", Value: "v$3", Domain: "golang.org", Path: "/pkg/", HttpOnly: true},
}
err := mozcookie.Write("testdata/cookie.txt", cookies)
if err != nil {
log.Fatalf("could not write cookies: %+v", err)
}cs, err := mozcookie.Read("testdata/cookie.txt")
if err != nil {
log.Fatalf("could not read cookies: %+v", err)
}fmt.Printf("cookies:\n")
for _, c := range cs {
fmt.Printf("%s: %q\n", c.Name, c.Value)
}
```## License
`mozcookie` is released under the `BSD-3` license.