This commit is contained in:
Liang Ding 2015-02-17 10:07:20 +08:00
parent ec0ca1e118
commit a0fefc5db8
2 changed files with 5 additions and 5 deletions

View File

@ -39,13 +39,11 @@ var logger = log.NewLogger(os.Stdout)
// IndexHandler handles request of Playground index.
func IndexHandler(w http.ResponseWriter, r *http.Request) {
username := "playground"
// create a HTTP session
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
if httpSession.IsNew {
httpSession.Values["id"] = strconv.Itoa(rand.Int())
httpSession.Values["username"] = username
httpSession.Values["username"] = "playground"
}
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
@ -54,6 +52,8 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
}
httpSession.Save(r, w)
username := httpSession.Values["username"].(string)
// create a wide session
rand.Seed(time.Now().UnixNano())
sid := strconv.Itoa(rand.Int())
@ -87,7 +87,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
wideSessions := session.WideSessions.GetByUsername(username)
logger.Tracef("User [%s] has [%d] sessions", username, len(wideSessions))
logger.Debugf("User [%s] has [%d] sessions", username, len(wideSessions))
t, err := template.ParseFiles("views/playground/index.html")

View File

@ -386,7 +386,7 @@ func (sessions *wSessions) Remove(sid string) {
}
}
logger.Tracef("Removed a session [%s] of user [%s], it has [%d] sessions currently", sid, s.Username, cnt)
logger.Debugf("Removed a session [%s] of user [%s], it has [%d] sessions currently", sid, s.Username, cnt)
return
}