當前位置: 首頁>>代碼示例>>Golang>>正文


Golang sessions.Session類代碼示例

本文整理匯總了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)
}
開發者ID:jameycribbs,項目名稱:battle_answers_go,代碼行數:7,代碼來源:search_answers.go

示例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
}
開發者ID:rday,項目名稱:martini-login,代碼行數:6,代碼來源:sessionauth.go

示例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")
}
開發者ID:rday,項目名稱:martini-login,代碼行數:5,代碼來源:sessionauth.go

示例4: Auth

func Auth(res http.ResponseWriter, req *http.Request, session sessions.Session) {
	if session.Get("login") != true {
		http.Error(res, "forbidden", http.StatusForbidden)
	}
}
開發者ID:Bootz,項目名稱:nzbcrawler,代碼行數:5,代碼來源:server.go

示例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)
}
開發者ID:jameycribbs,項目名稱:battle_answers_go,代碼行數:5,代碼來源:search_answers.go


注:本文中的github.com/codegangsta/martini-contrib/sessions.Session類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。