Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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驱动

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")
}