Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis session store ,Options not working #97

Open
ghost opened this issue Apr 17, 2016 · 1 comment
Open

Redis session store ,Options not working #97

ghost opened this issue Apr 17, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 17, 2016

    `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
Copy link

yes it is not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant