在使用 GetActiveSession 方法时获取的当期活跃的session用户,一段时间后在测试环境中登录的只有3个人登录,可活跃的session变为3000多,session我保存的是3600秒,不知道怎么解决与定位,session中我存了当前用信息。 球大家帮助解决,求不沉!
有疑问加站长微信联系(非本文作者)

在使用 GetActiveSession 方法时获取的当期活跃的session用户,一段时间后在测试环境中登录的只有3个人登录,可活跃的session变为3000多,session我保存的是3600秒,不知道怎么解决与定位,session中我存了当前用信息。 球大家帮助解决,求不沉!
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
`单行代码`
自己给自己顶!
是否应该提供下设置和获取 session 的关键代码?
session配置 sscfg := &session.ManagerConfig{ CookieName: "gosessionid", EnableSetCookie: true, Gclifetime: 3600, Maxlifetime: 3600, Secure: false, SessionIDHashFunc: "sha1", SessionIDHashKey: "sessionidkey", CookieLifeTime: 0, ProviderConfig: "", } 存session数据 func (self *LogonController) Post() { defer self.ServeJson() self.Data["host"] = self.Ctx.Request.Host userId := self.Ctx.Request.Form.Get("username") pwd := self.Ctx.Request.Form.Get("pwd") userBasic :=self.Ctx.Request.Form.Get("userbasic") log.Oper(userId, "Logon") sess := self.StartSession() sess.Set("username", userId)//存userID sess.Set("userBash64",userBasic)//存userbash64
} 取session数据 func(this *ControllerCommon) GetJiraProjectList() string { userBasic :=this.GetCurSessionUserBasic() client := &http.Client{} reqest, _ := http.NewRequest("GET", "http://jira.zte.com.cn/rest/api/2/project/", nil)
} //获取当前活跃用户数 func(this *ControllerCommon)GetSessionNum() int { return beego.GlobalSessions.GetActiveSession() }