{"id":13676616,"url":"https://github.com/gorilla/sessions","last_synced_at":"2025-05-12T13:18:41.309Z","repository":{"id":4896190,"uuid":"6051821","full_name":"gorilla/sessions","owner":"gorilla","description":"Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.","archived":false,"fork":false,"pushed_at":"2024-08-20T14:12:54.000Z","size":128,"stargazers_count":3043,"open_issues_count":7,"forks_count":374,"subscribers_count":55,"default_branch":"main","last_synced_at":"2025-05-12T13:18:20.411Z","etag":null,"topics":["cookie","go","golang","gorilla","gorilla-web-toolkit","sessions"],"latest_commit_sha":null,"homepage":"https://gorilla.github.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gorilla.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-10-02T21:33:02.000Z","updated_at":"2025-05-11T19:08:29.000Z","dependencies_parsed_at":"2022-07-10T20:02:37.636Z","dependency_job_id":"d55e634d-284c-4ffc-bc6b-c9e45b507e3e","html_url":"https://github.com/gorilla/sessions","commit_stats":{"total_commits":125,"total_committers":59,"mean_commits":"2.1186440677966103","dds":0.8240000000000001,"last_synced_commit":"bb4cd60c952a9ce48ea0dc6cc7b282ff79c38263"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fsessions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fsessions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fsessions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorilla%2Fsessions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gorilla","download_url":"https://codeload.github.com/gorilla/sessions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cookie","go","golang","gorilla","gorilla-web-toolkit","sessions"],"created_at":"2024-08-02T13:00:30.435Z","updated_at":"2025-05-12T13:18:41.182Z","avatar_url":"https://github.com/gorilla.png","language":"Go","readme":"# Gorilla Sessions\n\n\u003e [!IMPORTANT]\n\u003e The latest version of this repository requires go 1.23 because of the new partitioned attribute. The last version that is compatible with older versions of go is v1.3.0.\n\n![testing](https://github.com/gorilla/sessions/actions/workflows/test.yml/badge.svg)\n[![codecov](https://codecov.io/github/gorilla/sessions/branch/main/graph/badge.svg)](https://codecov.io/github/gorilla/sessions)\n[![godoc](https://godoc.org/github.com/gorilla/sessions?status.svg)](https://godoc.org/github.com/gorilla/sessions)\n[![sourcegraph](https://sourcegraph.com/github.com/gorilla/sessions/-/badge.svg)](https://sourcegraph.com/github.com/gorilla/sessions?badge)\n\n![Gorilla Logo](https://github.com/gorilla/.github/assets/53367916/d92caabf-98e0-473e-bfbf-ab554ba435e5)\n\ngorilla/sessions provides cookie and filesystem sessions and infrastructure for\ncustom session backends.\n\nThe key features are:\n\n- Simple API: use it as an easy way to set signed (and optionally\n  encrypted) cookies.\n- Built-in backends to store sessions in cookies or the filesystem.\n- Flash messages: session values that last until read.\n- Convenient way to switch session persistency (aka \"remember me\") and set\n  other attributes.\n- Mechanism to rotate authentication and encryption keys.\n- Multiple sessions per request, even using different backends.\n- Interfaces and infrastructure for custom session backends: sessions from\n  different stores can be retrieved and batch-saved using a common API.\n\nLet's start with an example that shows the sessions API in a nutshell:\n\n```go\n\timport (\n\t\t\"net/http\"\n\t\t\"github.com/gorilla/sessions\"\n\t)\n\n\t// Note: Don't store your key in your source code. Pass it via an\n\t// environmental variable, or flag (or both), and don't accidentally commit it\n\t// alongside your code. Ensure your key is sufficiently random - i.e. use Go's\n\t// crypto/rand or securecookie.GenerateRandomKey(32) and persist the result.\n\tvar store = sessions.NewCookieStore([]byte(os.Getenv(\"SESSION_KEY\")))\n\n\tfunc MyHandler(w http.ResponseWriter, r *http.Request) {\n\t\t// Get a session. We're ignoring the error resulted from decoding an\n\t\t// existing session: Get() always returns a session, even if empty.\n\t\tsession, _ := store.Get(r, \"session-name\")\n\t\t// Set some session values.\n\t\tsession.Values[\"foo\"] = \"bar\"\n\t\tsession.Values[42] = 43\n\t\t// Save it before we write to the response/return from the handler.\n\t\terr := session.Save(r, w)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n```\n\nFirst we initialize a session store calling `NewCookieStore()` and passing a\nsecret key used to authenticate the session. Inside the handler, we call\n`store.Get()` to retrieve an existing session or create a new one. Then we set\nsome session values in session.Values, which is a `map[interface{}]interface{}`.\nAnd finally we call `session.Save()` to save the session in the response.\n\nMore examples are available at [package documentation](https://pkg.go.dev/github.com/gorilla/sessions).\n\n## Store Implementations\n\nOther implementations of the `sessions.Store` interface:\n\n- [github.com/starJammer/gorilla-sessions-arangodb](https://github.com/starJammer/gorilla-sessions-arangodb) - ArangoDB\n- [github.com/yosssi/boltstore](https://github.com/yosssi/boltstore) - Bolt\n- [github.com/srinathgs/couchbasestore](https://github.com/srinathgs/couchbasestore) - Couchbase\n- [github.com/denizeren/dynamostore](https://github.com/denizeren/dynamostore) - Dynamodb on AWS\n- [github.com/savaki/dynastore](https://github.com/savaki/dynastore) - DynamoDB on AWS (Official AWS library)\n- [github.com/bradleypeabody/gorilla-sessions-memcache](https://github.com/bradleypeabody/gorilla-sessions-memcache) - Memcache\n- [github.com/dsoprea/go-appengine-sessioncascade](https://github.com/dsoprea/go-appengine-sessioncascade) - Memcache/Datastore/Context in AppEngine\n- [github.com/kidstuff/mongostore](https://github.com/kidstuff/mongostore) - MongoDB\n- [github.com/srinathgs/mysqlstore](https://github.com/srinathgs/mysqlstore) - MySQL\n- [github.com/danielepintore/gorilla-sessions-mysql](https://github.com/danielepintore/gorilla-sessions-mysql) - MySQL\n- [github.com/EnumApps/clustersqlstore](https://github.com/EnumApps/clustersqlstore) - MySQL Cluster\n- [github.com/antonlindstrom/pgstore](https://github.com/antonlindstrom/pgstore) - PostgreSQL\n- [github.com/boj/redistore](https://github.com/boj/redistore) - Redis\n- [github.com/rbcervilla/redisstore](https://github.com/rbcervilla/redisstore) - Redis (Single, Sentinel, Cluster)\n- [github.com/boj/rethinkstore](https://github.com/boj/rethinkstore) - RethinkDB\n- [github.com/boj/riakstore](https://github.com/boj/riakstore) - Riak\n- [github.com/michaeljs1990/sqlitestore](https://github.com/michaeljs1990/sqlitestore) - SQLite\n- [github.com/wader/gormstore](https://github.com/wader/gormstore) - GORM (MySQL, PostgreSQL, SQLite)\n- [github.com/gernest/qlstore](https://github.com/gernest/qlstore) - ql\n- [github.com/quasoft/memstore](https://github.com/quasoft/memstore) - In-memory implementation for use in unit tests\n- [github.com/lafriks/xormstore](https://github.com/lafriks/xormstore) - XORM (MySQL, PostgreSQL, SQLite, Microsoft SQL Server, TiDB)\n- [github.com/GoogleCloudPlatform/firestore-gorilla-sessions](https://github.com/GoogleCloudPlatform/firestore-gorilla-sessions) - Cloud Firestore\n- [github.com/stephenafamo/crdbstore](https://github.com/stephenafamo/crdbstore) - CockroachDB\n- [github.com/ryicoh/tikvstore](github.com/ryicoh/tikvstore) - TiKV\n\n## License\n\nBSD licensed. See the LICENSE file for details.\n","funding_links":[],"categories":["开源类库","Misc","Middlewares \u0026 framework add-ons","Open source library","Go","Repositories"],"sub_categories":["Auth"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorilla%2Fsessions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgorilla%2Fsessions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorilla%2Fsessions/lists"}