beego框架之cookie与session

this.Ctx.SetCookie("name", name, maxage, "/")

this.Ctx.SetCookie("pwd", Md5([]byte(pwd)), maxage, "/")

this.Ctx.GetCookie

beego 内置了 session 模块,目前 session 模块支持的后端引擎包括 memory、cookie、file、mysql、redis、couchbase、memcache、postgres,用户也可以根据相应的 interface 实现自己的引擎。

beego 中使用 session 相当方便,只要在 main 入口函数中设置如下:

image.png

或者通过配置文件配置如下:

image.png

session 有几个方便的方法:

image.png



猜你喜欢

转载自blog.51cto.com/5660061/2369027