Open ghost opened 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
yes it is not working
` controllers.Home
` func Home(c *gin.Context) {
}`
/home return {"count":0} with no cookie