sessions
sessions copied to clipboard
How to delete a single session?
engine := gin.Default()
engine.SetFuncMap(utils.GetTemplateFuncMap())
engine.Static("/assets", "../assets")
engine.LoadHTMLGlob("../views/**/**/*")
store := cookie.NewStore([]byte(config.Conf.Session.Secret))
if config.Conf.Session.MaxAge > 0 {
store.Options(sessions.Options{MaxAge: config.Conf.Session.MaxAge, Path: "/"})
}
engine.Use(sessions.Sessions(config.Conf.Session.Name, store))
route.RegisterBackendRoute(engine)
route.RegisterFrontedRoute(engine)
if err := engine.Run(":8081"); err != nil {
log.Fatalf("server running error: %v", err)
}
func (c *BaseContext) Forget() {
c.session.Delete(userKey)
_ = c.session.Save()
}
When I set the session lifetime, the session cannot be deleted normally by calling the logout method. If I don't set the lifetime, it can work normally. Why is this?
@hhandhuan I encoutered this issue as well, any workaround to fix this? And this issue is wired as comparing to Java servlet session....