We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4a0c802 commit 7702fe9Copy full SHA for 7702fe9
14.2.md
@@ -55,6 +55,28 @@ beego中主要有如下这些全局变量来控制session处理:
55
## session使用
56
通过上面的代码我们可以看到,beego框架很方便的就继承了session功能,那么我们在项目中如何使用呢?请看的示例代码:
57
58
+ func (this *MainController) Get() {
59
+ var intcount int
60
+ sess := this.StartSession()
61
+ count := sess.Get("count")
62
+ if count == nil {
63
+ intcount = 0
64
+ } else {
65
+ intcount = count.(int)
66
+ }
67
+ intcount = intcount + 1
68
+ sess.Set("count", intcount)
69
+ this.Data["Username"] = "astaxie"
70
+ this.Data["Email"] = "[email protected]"
71
+ this.Data["Count"] = intcount
72
+ this.TplNames = "index.tpl"
73
74
+
75
+上面的代码展示了如何在我们自己的控制逻辑中使用session,主要分两个步骤:
76
77
+1. 获取session对象
78
79
+2. 使用session进行一般的session值操作
80
81
82
0 commit comments