diff --git a/conf/app.conf b/conf/app.conf index 4913e20..4cf34af 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -8,3 +8,4 @@ logspath = "./logs/" loglevel = "info" uploadspath = "./uploads/" sqlitedbfilepath = "./tasks.db" +sessionkey = "common-nisd" diff --git a/controllers/db.go b/controllers/db.go index 74b9abd..3140419 100644 --- a/controllers/db.go +++ b/controllers/db.go @@ -42,8 +42,8 @@ func (this *DatabaseController) Connect() { m["nsid"] = nsid res.Data = nsid this.Ctx.SetCookie("Secure", "true") - this.Ctx.SetCookie("SameSite", "None") - this.SetSession("nsid", nsid) + this.Ctx.SetCookie("SameSite", "Strict") + this.SetSession(beego.AppConfig.String("sessionkey"), nsid) res.Message = "Login successfully" } else { @@ -65,7 +65,7 @@ func (this *DatabaseController) Home() { func (this *DatabaseController) Disconnect() { var res Response - nsid := this.GetSession("nsid") + nsid := this.GetSession(beego.AppConfig.String("sessionkey")) if nsid != nil { dao.Disconnect(nsid.(string)) } @@ -78,7 +78,7 @@ func (this *DatabaseController) Disconnect() { func (this *DatabaseController) Execute() { var res Response var params ExecuteRequest - nsid := this.GetSession("nsid") + nsid := this.GetSession(beego.AppConfig.String("sessionkey")) if nsid == nil { res.Code = -1 res.Message = "connection refused for lack of session" diff --git a/main.go b/main.go index 02a0e37..72033e7 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ func main() { */ beego.BConfig.WebConfig.Session.SessionCookieLifeTime = 0 beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 60 * 60 * 24 - beego.BConfig.WebConfig.Session.SessionName = "nsid" + beego.BConfig.WebConfig.Session.SessionName = beego.AppConfig.String("sessionkey") beego.BConfig.WebConfig.Session.SessionOn = true /* @@ -66,7 +66,7 @@ func main() { logs.SetLogFuncCall(true) logs.SetLogFuncCallDepth(3) logs.SetLevel(logLevel) - defer func(){ + defer func() { logs.GetBeeLogger().Flush() }()