1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-10 12:40:19 +00:00

session destroy

This commit is contained in:
astaxie
2016-01-18 16:11:27 +08:00
parent 6e987bfdaf
commit fa8f6e5a53
4 changed files with 5 additions and 71 deletions

View File

@ -98,18 +98,13 @@ func (rs *SessionStore) SessionID() string {
// SessionRelease save session values to redis
func (rs *SessionStore) SessionRelease(w http.ResponseWriter) {
b, err := session.EncodeGob(rs.values)
if err != nil {
return
}
c := rs.p.Get()
defer c.Close()
// Update session value if exists or error.
if existed, err := redis.Bool(c.Do("EXISTS", rs.sid)); existed || err != nil {
c.Do("SETEX", rs.sid, rs.maxlifetime, string(b))
}
c.Do("SETEX", rs.sid, rs.maxlifetime, string(b))
}
// Provider redis session provider