{"id":20968817,"url":"https://github.com/phachon/fasthttpsession","last_synced_at":"2025-05-14T09:34:03.479Z","repository":{"id":55436567,"uuid":"128914991","full_name":"phachon/fasthttpsession","owner":"phachon","description":"A fast and powerful session package for fasthttp servers","archived":false,"fork":false,"pushed_at":"2020-12-17T06:11:16.000Z","size":2525,"stargazers_count":25,"open_issues_count":0,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-06-18T23:05:32.551Z","etag":null,"topics":["fasthttp","fasthttpclient","fasthttprouter","fasthttpsession","go","go-session","go-sessions","golang","httprouter","php-sessions","session","session-cookie","session-management","session-manager","session-store","sessionstorage","sessionstore"],"latest_commit_sha":null,"homepage":"","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/phachon.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":"2018-04-10T10:24:51.000Z","updated_at":"2024-06-18T23:05:32.552Z","dependencies_parsed_at":"2022-08-15T00:20:14.942Z","dependency_job_id":null,"html_url":"https://github.com/phachon/fasthttpsession","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Ffasthttpsession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Ffasthttpsession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Ffasthttpsession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Ffasthttpsession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phachon","download_url":"https://codeload.github.com/phachon/fasthttpsession/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225285687,"owners_count":17450061,"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":["fasthttp","fasthttpclient","fasthttprouter","fasthttpsession","go","go-session","go-sessions","golang","httprouter","php-sessions","session","session-cookie","session-management","session-manager","session-store","sessionstorage","sessionstore"],"created_at":"2024-11-19T03:16:54.013Z","updated_at":"2024-11-19T03:16:54.499Z","avatar_url":"https://github.com/phachon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![logo](./logo.png)](https://github.com/phachon/fasthttpsession)\n\n[![Sourcegraph](https://sourcegraph.com/github.com/phachon/fasthttpsession/-/badge.svg)](https://sourcegraph.com/github.com/phachon/fasthttpsession?badge)\n[![build](https://img.shields.io/shippable/5444c5ecb904a4b21567b0ff.svg)](https://travis-ci.org/phachon/fasthttpsession)\n[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/phachon/fasthttpsession)\n[![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/phachon/fasthttpsession/master/LICENSE)\n[![go_Report](https://goreportcard.com/badge/github.com/phachon/fasthttpsession)](https://goreportcard.com/report/github.com/phachon/fasthttpsession)\n[![release](https://img.shields.io/github/release/phachon/fasthttpsession.svg?style=flat)](https://github.com/phachon/fasthttpsession/releases) \n[![powered_by](https://img.shields.io/badge/powered_by-Go-3362c2.svg?style=flat)]()\n[![platforms](https://img.shields.io/badge/platform-All-yellow.svg?style=flat)]()\n\nfasthttpsession is a fast and powerful session package for [fasthttp](https://github.com/valyala/fasthttp) servers\n\n[中文文档](./README_CN.md)\n\n# Description\n\nfasthttpsession is a session manager for Go. It only supports [fasthttp](https://github.com/valyala/fasthttp), currently support providers:\n\n- file\n- memcache\n- memory\n- mysql\n- postgres\n- redis\n- sqlite3\n\n# Features\n\n- Focus on the design of the code architecture and expansion.\n- Provide full session storage.\n- Convenient switching of session storage.\n- Customizable data serialization.\n- Implement concurrent map(ccmap.go) to improve performance.\n\n# Install\n\nThe only requirement is the Go Programming Language, at least v1.7\n\n```shell\n$ go get -u github.com/phachon/fasthttpsession\n$ go get ./...\n```\n\n# Used\n\n## Quick Start\n```Golang\n\n// fasthttpsession use memory provider\n\nimport (\n\t\"github.com/phachon/fasthttpsession\"\n\t\"github.com/phachon/fasthttpsession/memory\"\n\t\"github.com/valyala/fasthttp\"\n\t\"log\"\n\t\"os\"\n)\n\n// default config\nvar session = fasthttpsession.NewSession(fasthttpsession.NewDefaultConfig())\n\nfunc main()  {\n\t// you must set up provider before use\n\terr := session.SetProvider(\"memory\", \u0026memory.Config{})\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\tos.Exit(1)\n\t}\n\taddr := \":8086\"\n\tlog.Println(\"fasthttpsession example server listen: \"+addr)\n\t\n\t// fasthttp start listen serve\n\terr = fasthttp.ListenAndServe(addr, requestHandle)\n\tif err != nil {\n\t\tlog.Println(\"listen server error :\"+err.Error())\n\t}\n}\n\n// request handler\nfunc requestHandle(ctx *fasthttp.RequestCtx) {\n\t// start session\n\tsessionStore, err := session.Start(ctx)\n\tif err != nil {\n\t\tctx.SetBodyString(err.Error())\n\t\treturn\n\t}\n\t// must defer sessionStore.save(ctx)\n\tdefer sessionStore.Save(ctx)\n\n\tsessionStore.Set(\"name\", \"fasthttpsession\")\n\n\tctx.SetBodyString(fmt.Sprintf(\"fasthttpsession setted key name= %s ok\", sessionStore.Get(\"name\").(string)))\n}\n```\n\n## Custom configuration\n\nIf you don't want to use the default configuration, please use the following struct custom.\n```Golang\ntype Config struct {\n\n\t// cookie name\n\tCookieName string\n\t\n\t// cookie domain\n\tDomain string\n\t\n\t// If you want to delete the cookie when the browser closes, set it to -1.\n\t//\n\t//  0 means no expire, (24 years)\n\t// -1 means when browser closes\n\t// \u003e0 is the time.Duration which the session cookies should expire.\n\tExpires time.Duration\n\t\n\t// gc life time(s)\n\tGCLifetime int64\n\t\n\t// session life time(s)\n\tSessionLifetime int64\n\t\n\t// set whether to pass this bar cookie only through HTTPS\n\tSecure bool\n\t\n\t// sessionId is in url query\n\tSessionIdInURLQuery bool\n\t\n\t// sessionName in url query\n\tSessionNameInUrlQuery string\n\t\n\t// sessionId is in http header\n\tSessionIdInHttpHeader bool\n\t\n\t// sessionName in http header\n\tSessionNameInHttpHeader string\n\t\n\t// SessionIdGeneratorFunc should returns a random session id.\n\tSessionIdGeneratorFunc func() string\n\t\n\t// Encode the cookie value if not nil.\n\tEncodeFunc func(cookieValue string) (string, error)\n\t\n\t// Decode the cookie value if not nil.\n\tDecodeFunc func(cookieValue string) (string, error)\n}\n```\n\nDifferent session provider config, please look at the Config.go the provider name directory.\n\n# Documents\n\nDocument address: [http://godoc.org/github.com/phachon/fasthttpsession](http://godoc.org/github.com/phachon/fasthttpsession)\n\n# Example\n\n[Some Example](_examples)\n\n## Feedback\n\n- If you like the project, please [Start](https://github.com/phachon/fasthttpsession/stargazers).\n- If you have any problems in the process of use, welcome submit [Issue](https://github.com/phachon/fasthttpsession/issues).\n- If you find and solve bug, welcome submit [Pull Request](https://github.com/phachon/fasthttpsession/pulls).\n- If you want to expand session provider, welcome [Fork](https://github.com/phachon/fasthttpsession/network/members) and merge this rep.\n- If you want to make a friend, welcome send email to [phachon@163.com](mailto:phachon@163.com).\n\n## License\n\nMIT\n\nThanks\n---------\nCreate By phachon@163.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphachon%2Ffasthttpsession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphachon%2Ffasthttpsession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphachon%2Ffasthttpsession/lists"}