Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/libi/gin-session
go gin框架的session中间件, 目前只实现了redis驱动
https://github.com/libi/gin-session
Last synced: 6 days ago
JSON representation
go gin框架的session中间件, 目前只实现了redis驱动
- Host: GitHub
- URL: https://github.com/libi/gin-session
- Owner: libi
- Created: 2015-11-19T08:54:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-19T09:34:18.000Z (almost 9 years ago)
- Last Synced: 2024-06-20T17:18:33.299Z (5 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gin-session
go gin框架的session中间件, 目前只实现了redis驱动使用方法
func main(){
g := gin.New()session_config := `{
"storeDriver":"redis",
"cookieName":"session_id",
"EnableSetCookie":true,
"secure":false,
"cookieLifeTime": 3,
"Domain":""
}`
s := g.Group("/")
s.Use(gsession.Middleware(session_config))
{
s.GET("/",func(c *gin.Context){
sess := gsession.GetSession(c);
sess.Set("uid","22")
})
s.GET("/member",func(c *gin.Context){
sess := gsession.GetSession(c);
uid := sess.Get("uid")
fmt.Println(uid)
})
}
g.Run(":8888")
}