diff --git a/src/Cm/RedisSession/Handler.php b/src/Cm/RedisSession/Handler.php index 3d34aff..0154f96 100644 --- a/src/Cm/RedisSession/Handler.php +++ b/src/Cm/RedisSession/Handler.php @@ -666,6 +666,21 @@ public function destroy($sessionId) */ public function close() { + $id = session_id(); + $sessionId = 'sess_' . $id; + + if ( ! $this->_useLocking + || ( ! ($pid = $this->_redis->hGet('sess_'.$sessionId, 'pid')) || $pid == $this->_getPid()) + ) { + $this->_redis->pipeline() + ->select($this->_dbNum) + ->hMSet($sessionId, array( + 'lock' => 0, // 0 so that next lock attempt will get 1 + )) + ->expire($sessionId, min($this->getLifeTime(), $this->_maxLifetime)) + ->exec(); + } + $this->_log("Closing connection"); if ($this->_redis) $this->_redis->close(); return true;