session控制
开启session
sessionon = truebeego.BConfig.WebConfig.Session.SessionOn = true示例
func (controller *MainController) Get() {
username := controller.GetSession("username")
password := controller.GetSession("password")
if username == nil || password == nil {
controller.SetSession("username", "peng")
controller.SetSession("password", "123456")
controller.Ctx.WriteString("username or password not set")
} else {
controller.Ctx.WriteString("username : " + username.(string) + ", password : " + password.(string))
}
}session的其他配置
Reference
Last updated