Skip to content

Commit

Permalink
Enhance Web Pannel Security by setting session valid time
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzKafkaYu committed Apr 23, 2022
1 parent b616a5b commit 6c5bbfe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package session

import (
"encoding/gob"
"x-ui/database/model"

"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"x-ui/database/model"
)

const (
Expand All @@ -18,6 +19,10 @@ func init() {
func SetLoginUser(c *gin.Context, user *model.User) error {
s := sessions.Default(c)
s.Set(loginUser, user)
s.Options(sessions.Options{
MaxAge: 7200,
Secure: true,
})
return s.Save()
}

Expand Down

0 comments on commit 6c5bbfe

Please sign in to comment.