Example #1
0
// GetSession returns the session
func GetSession(r *http.Request) *sessions.Session {
	sess, err := getStore().Get(r, config.Get("SESSION_NAME"))
	if err != nil {
		log.Fatal(err)
	}

	return sess
}
Example #2
0
// GetStore will return the store. If the store does not exist, it will create and return
func getStore() *sessions.CookieStore {
	// If sessionstore has already been initialized, return that
	if sessionStore != nil {
		return sessionStore
	}

	//If not, then initialize it and return
	sessionStore := sessions.NewCookieStore([]byte(config.Get("SESSION_HASH")))
	return sessionStore
}