gin-gonic / contrib

Collection of middlewares created by the community
https://gin-gonic.github.io/gin/
MIT License
2.02k stars 278 forks source link

Redis session store ,Options not working #97

Open ghost opened 8 years ago

ghost commented 8 years ago
    `s := gin.New()
s.Use(gin.Recovery())
s.Use(gin.Logger())
store, _ := sessions.NewRedisStore(10, "tcp", "192.168.99.100:32775", "", []byte("secret"))
store.Options(sessions.Options{
    MaxAge: 3600,
    Path: "/",
    Secure: true,
    HttpOnly: true,
})
s.Use(sessions.Sessions("session", store))
s.GET("/home",controllers.Home)

` controllers.Home

` func Home(c *gin.Context) {

s := sessions.Default(c)
var count int
v := s.Get("count")
if v == nil {
    count = 0
} else {
    count = v.(int)
    count += 1
}
s.Set("count", count)
s.Save()

c.JSON(200, gin.H{"count": count})

}`


/home return {"count":0} with no cookie

demonwang commented 7 years ago

yes it is not working