This commit is contained in:
life
2015-03-31 14:27:26 +08:00
parent 9515f1e58f
commit decf580ed3
585 changed files with 8128 additions and 9023 deletions

View File

@ -69,3 +69,20 @@ func (this *SessionService) SetCaptcha(sessionId, captcha string) bool {
Log(ok)
return ok
}
//-----------
// API
func (this *SessionService) GetUserId(sessionId string) string {
session := this.Get(sessionId)
// 更新updateTime, 避免过期
db.UpdateByQMap(db.Sessions, bson.M{"SessionId": sessionId},
bson.M{"UpdatedTime": time.Now()})
return session.UserId
}
// 登录成功后设置userId
func (this *SessionService) SetUserId(sessionId, userId string) bool {
this.Get(sessionId)
ok := this.Update(sessionId, "UserId", userId)
return ok
}