本文整理匯總了Golang中github.com/codegangsta/martini-contrib/sessions.Session類的典型用法代碼示例。如果您正苦於以下問題:Golang Session類的具體用法?Golang Session怎麽用?Golang Session使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Session類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SearchAnswersNew
func SearchAnswersNew(r render.Render, db *mgo.Database, req *http.Request, session sessions.Session) {
lastGameIdSearched := session.Get("last_game_id_searched")
templateData := map[string]interface{}{"metatitle": "Battle Answers", "currentPath": req.URL.Path,
"lastGameIdSearched": lastGameIdSearched, "games": models.GetGameRecs(db, nil)}
r.HTML(200, "search_answers/new", templateData)
}
示例2: UpdateUser
// UpdateUser updates the User object stored in the session. This is useful incase a change
// is made to the user model that needs to persist across requests.
func UpdateUser(s sessions.Session, user User) error {
s.Set("AUTHUNIQUEID", user.UniqueId())
return nil
}
示例3: Logout
// Logout will clear out the session and call the Logout() user function.
func Logout(s sessions.Session, user User) {
user.Logout()
s.Delete("AUTHUNIQUEID")
}
示例4: Auth
func Auth(res http.ResponseWriter, req *http.Request, session sessions.Session) {
if session.Get("login") != true {
http.Error(res, "forbidden", http.StatusForbidden)
}
}
示例5: SearchAnswersCreate
func SearchAnswersCreate(form SearchAnswerForm, r render.Render, db *mgo.Database, req *http.Request, session sessions.Session) {
session.Set("last_game_id_searched", form.GameId)
SearchAnswersIndex(r, db, form.GameId, form.Keywords, req)
}