- Install the github.com/astaxie/beego/session/redis package using the go get command, as follows:
$ go get -u github.com/astaxie/beego/session/redis
- Move to $GOPATH/src/my-first-beego-project/controllers and create sessioncontroller.go, where we will define handlers which make sure that only authenticated users can view the home page, as follows:
package controllers import "github.com/astaxie/beego"type SessionController struct { beego.Controller}func (this *SessionController) Home() { isAuthenticated := this.GetSession("authenticated") if isAuthenticated == nil || isAuthenticated == false { this.Ctx.WriteString("You are unauthorized to view the page.") return } this.Ctx.ResponseWriter.WriteHeader(200) this.Ctx.WriteString("Home ...