Fix section "Using sessions" in 14.2.md
This commit is contained in:
19
en/14.2.md
19
en/14.2.md
@@ -56,16 +56,15 @@ To assist us in quickly using sessions in a custom Controller, `beego.Controller
|
||||
return
|
||||
}
|
||||
|
||||
## Session using
|
||||
## Using sessions
|
||||
|
||||
Through the above code we can see, beego framework simply inherit the session function, then how to use it in your project ?
|
||||
From the code above, we can see that the Beego framework simply inherits its session functionality. So, how do we use it in our projects?
|
||||
|
||||
First, we need to apply the main entrance open session:
|
||||
First of all, we need to open the session at the entry point of our application.
|
||||
|
||||
beego.SessionOn = true
|
||||
|
||||
|
||||
We can then corresponding method in the controller to use the session as follows: the
|
||||
We can then use the corresponding session method inside our controller like so:
|
||||
|
||||
func (this *MainController) Get() {
|
||||
var intcount int
|
||||
@@ -84,14 +83,14 @@ We can then corresponding method in the controller to use the session as follows
|
||||
this.TplNames = "index.tpl"
|
||||
}
|
||||
|
||||
The above code shows how to use the control logic session, mainly divided into two steps:
|
||||
The code above shows how to use sessions in the controller logic. The process can be divided into two steps:
|
||||
|
||||
1. Get session object
|
||||
1. Getting session object
|
||||
|
||||
// Get the object, similar in PHP session_start()
|
||||
sess:= this.StartSession()
|
||||
|
||||
2. to use the session for general session value operation
|
||||
2. Using the session for general operations
|
||||
|
||||
// Get the session values , similar in PHP $ _SESSION ["count"]
|
||||
sess.Get("count")
|
||||
@@ -99,10 +98,10 @@ The above code shows how to use the control logic session, mainly divided into t
|
||||
// Set the session value
|
||||
sess.Set("count", intcount)
|
||||
|
||||
As can be seen from the above code beego framework based applications developed using the session quite easy, basically, and PHP to call `session_start()` similar.
|
||||
As you can see, applications based on the Beego framework can easily implement sessions. The process is very similar to calling `session_start()` in PHP applications.
|
||||
|
||||
## Links
|
||||
|
||||
- [Directory](preface.md)
|
||||
- Previous section: [Static files](14.1.md)
|
||||
- Next section: [Form](14.3.md)
|
||||
- Next section: [Forms](14.3.md)
|
||||
|
||||
Reference in New Issue
Block a user