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

How to delete a single session? #192

Open
hhandhuan opened this issue Sep 9, 2022 · 1 comment
Open

How to delete a single session? #192

hhandhuan opened this issue Sep 9, 2022 · 1 comment

Comments

@hhandhuan
Copy link

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?

@jeven2016
Copy link

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

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

2 participants