Strengthens the session's function
This commit is contained in:
@@ -35,6 +35,11 @@ func (rs *RedisSessionStore) Delete(key interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (rs *RedisSessionStore) Flush() error {
|
||||
_, err := rs.c.Do("DEL", rs.sid)
|
||||
return err
|
||||
}
|
||||
|
||||
func (rs *RedisSessionStore) SessionID() string {
|
||||
return rs.sid
|
||||
}
|
||||
@@ -99,6 +104,16 @@ func (rp *RedisProvider) SessionRead(sid string) (SessionStore, error) {
|
||||
return rs, nil
|
||||
}
|
||||
|
||||
func (rp *RedisProvider) SessionRegenerate(oldsid, sid string) (SessionStore, error) {
|
||||
c := rp.connectInit()
|
||||
if str, err := redis.String(c.Do("HGET", oldsid, oldsid)); err != nil || str == "" {
|
||||
c.Do("HSET", oldsid, oldsid, rp.maxlifetime)
|
||||
}
|
||||
c.Do("RENAME", oldsid, sid)
|
||||
rs := &RedisSessionStore{c: c, sid: sid}
|
||||
return rs, nil
|
||||
}
|
||||
|
||||
func (rp *RedisProvider) SessionDestroy(sid string) error {
|
||||
c := rp.connectInit()
|
||||
c.Do("DEL", sid)
|
||||
|
||||
Reference in New Issue
Block a user