sessions icon indicating copy to clipboard operation
sessions copied to clipboard

How to delete a single session?

Open hhandhuan opened this issue 1 year ago • 1 comments

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 avatar Sep 09 '22 06:09 hhandhuan

@hhandhuan I encoutered this issue as well, any workaround to fix this? And this issue is wired as comparing to Java servlet session....

jeven2016 avatar Dec 04 '22 06:12 jeven2016