BEEGO session写入,读取
2016-07-12 17:03
429 查看
package controllers import ( //"encoding/json" "github.com/astaxie/beego" "github.com/astaxie/beego/cache" _ "github.com/astaxie/beego/cache/redis" "github.com/astaxie/beego/session" "github.com/garyburd/redigo/redis" ) func init() { globalSessionsTest, _ = session.NewManager("memory", `{"cookieName":"gosessionid","gclifetime":3600}`) go globalSessionsTest.GC() } var globalSessionsTest *session.Manager // Operations about Locals type LocalController struct { beego.Controller } // @Title createLocal // @Description request interface // @Param body body models.Local true "body for proxy content" // @Success 200 {object} models.Local // @Failure 403 :uid is empty // @router / [post] func (this *LocalController) Oauth() { var ( appid, pid, sign, action string ) this.Ctx.Input.Bind(&pid, "pid") this.Ctx.Input.Bind(&appid, "app_id") this.Ctx.Input.Bind(&sign, "sign") this.Ctx.Input.Bind(&action, "action") /** * 参数验证 */ if len(sign) == 0 || len(action) == 0 || len(appid) == 0 || len(pid) == 0 { this.Data["json"] = JsonFormat(SYS_MISS_PARAMS, "miss params", nil) this.ServeJSON() } sess, _ := globalSessionsTest.SessionStart(this.Ctx.ResponseWriter, this.Ctx.Request) sess.Set("Session", "set session") sessionValue := sess.Get("Session") beego.Notice("session:") beego.Notice(sessionValue.(string)) }
相关文章推荐
- go strings 常用的几个函数
- usaco contest 2008.11 gold 安慰奶牛
- .gitigore 相关
- category
- ssh-host-config 28: syntax error: got (, expecting Newline
- Google的Google Chart Tools使用
- Django高级视图和URL配置
- ubuntu 16.04 LTS 下Robomongo 无法输入中文的问题
- 大话设计模式(golang) 三、装饰模式
- Sunday Algorithm
- 在Django中使用DISTINCT
- ORA-01017: invalid username/password; logon denied 解决办法
- 在Leangoo里怎么修改昵称,简称,头像?
- Django程序开发基本步骤
- Leangoo用户设置在哪里?
- USACO - Oct08 Gold Watering Hole 挖井 Kruskal演算法+点权转边权
- 在Django中使用DISTINCT
- django工作原理
- Google的高级搜索
- Django模板系统