mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 14:57:16 +08:00
feat: session支持刷新
This commit is contained in:
@@ -33,6 +33,20 @@ func Session() http.Middleware {
|
||||
return
|
||||
}
|
||||
|
||||
// 刷新会话
|
||||
if err := ctx.Request().Session().Regenerate(); err == nil {
|
||||
ctx.Response().Cookie(http.Cookie{
|
||||
Name: ctx.Request().Session().GetName(),
|
||||
Value: ctx.Request().Session().GetID(),
|
||||
MaxAge: facades.Config().GetInt("session.lifetime") * 60,
|
||||
Path: facades.Config().GetString("session.path"),
|
||||
Domain: facades.Config().GetString("session.domain"),
|
||||
Secure: facades.Config().GetBool("session.secure"),
|
||||
HttpOnly: facades.Config().GetBool("session.http_only"),
|
||||
SameSite: facades.Config().GetString("session.same_site"),
|
||||
})
|
||||
}
|
||||
|
||||
ctx.WithValue("user_id", userID)
|
||||
ctx.Request().Next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user