Release a session back to the pool.

@param Session $session The session.
496006
public function release(Session $session)
    {
        $this->config['lock']->synchronize(function () use ($session) {
            $item = $this->cacheItemPool->getItem($this->cacheKey);
            $data = $item->get();
            $name = $session->name();

            if (isset($data['inUse'][$name])) {
                unset($data['inUse'][$name]);
                array_push($data['queue'], [
                    'name' => $name,
                    'expiration' => $session->expiration()
                        ?: $this->time() + SessionPoolInterface::SESSION_EXPIRATION_SECONDS
                ]);
                $this->cacheItemPool->save($item->set($data));
            }
        });
    }
666704
private void free(IoSession session) {
        IoBuffer buf = buffersMap.remove(session);
        if (buf != null) {
            buf.free();
        }
    }
96922
protected function setCookieFromSession($session=null) {
    if (!$this->useCookieSupport()) {
      return;
    }

    $cookieName = $this->getSessionCookieName();
    $value = 'deleted';
    $expires = time() - 3600;
    $domain = $this->getBaseDomain();
    if ($session) {
      $value = '"' . http_build_query($session, null, '&') . '"';
      if (isset($session['base_domain'])) {
        $domain = $session['base_domain'];
      }
      $expires = $session['expires'];
    }

    // prepend dot if a domain is found
    if ($domain) {
      $domain = '.' . $domain;
    }

    // if an existing cookie is not set, we dont need to delete it
    if ($value == 'deleted' && empty($_COOKIE[$cookieName])) {
      return;
    }

    if (headers_sent()) {
      self::errorLog('Could not set cookie. Headers already sent.');

    // ignore for code coverage as we will never be able to setcookie in a CLI
    // environment
    // @codeCoverageIgnoreStart
    } else {
      setcookie($cookieName, $value, $expires, '/', $domain);
    }
    // @codeCoverageIgnoreEnd
  }
810397
public function remove($key = null)
    {
        if ($this->resumeSession()) {
            if ($key) {
                if (isset($_SESSION[$this->name]) && \array_key_exists($key, $_SESSION[$this->name])) {
                    unset($_SESSION[$this->name][$key]);
                }
            } else {
                unset($_SESSION[$this->name]);
            }
        }
    }
472491
private function storeUserSession($session)
    {
        // get all sessions
        $sessions = $this->getMeta()->sessions->val();
        if (!is_array($sessions)) {
            $sessions = [];
        }

        // delete the old sessions
        $newSessions = [];
        $ttl = $this->getSessionTtl();
        foreach ($sessions as $s) {
            if (($s['created'] + $ttl) > time()) {
                $newSessions[] = $s;
            }
        }

        // append the new session
        $newSessions[] = ['sid' => $session, 'created' => time(), 'ip' => $this->ip];

        // update the last login date
        $this->getMeta()->lastLogin = time();

        // append a new login attempt
        $this->getMeta()->loginAttempts[] = ['ip' => $this->ip, 'timestamp' => time()];

        // update the entity
        $this->getMeta()->sessions = $newSessions;
        $this->getMeta()->save();
    }
721079
private function processError(Session $session, ErrorMessage $msg)
    {
        switch ($msg->getErrorMsgCode()) {
            case Message::MSG_INVOCATION:
                $this->processInvocationError($session, $msg);
                break;
            case Message::MSG_INTERRUPT:
                $this->processInterruptError($session, $msg);
                break;
        }
    }
630712
public function setSession($session)
    {
        if (is_object($session)) {
            $this->session = $session;
        } elseif (is_string($session) || is_array($session)) {
            $this->session = new Session($session);
        }
    }
98171
private function handleSession(array $session)
    {
        if ($this->isSessionValid($session)) {
            return $session;
        }

        $this->config['lock']->synchronize(function () use ($session) {
            $item = $this->cacheItemPool->getItem($this->cacheKey);
            $data = $item->get();
            unset($data['inUse'][$session['name']]);
            $this->cacheItemPool->save($item->set($data));
        });
    }
201916
public function registerSession($name, Session $session)
    {
        $name = strtolower($name);

        $this->sessions[$name] = $session;
    }
356956
public void removeHttpSession(HttpSession session) {
		if (session == activeSession) {
			activeSession = null;
		}
		synchronized (this.sessions) {
			this.sessions.remove(session);
		}
		this.model.removeHttpSession(session);
		session.invalidate();
	}
758330
protected function unlock_session($id) {
        if (isset($this->locks[$id])) {
            $this->connection->del($id.".lock");
            unset($this->locks[$id]);
        }
    }
1224273
private static function session($session)
    {
        $files = ['Session'];
        $folder = static::$root.'Storage'.'/';

        self::call($files, $folder);

        $files = ['SessionKeyNotFoundException', 'SessionSurfaceIsOffException'];
        $folder = static::$root.'Storage/Exceptions'.'/';

        self::call($files, $folder);

        //Initiat the class
        if ($session) {
            Session::ini();
        }
    }
152907
public function remove($key): void
    {
        foreach ((array) $key as $key) {
            unset($_SESSION[$this->name][$key]);
        }
    }
1230804
public function enableSession($session = null)
    {
        $session = $session instanceof Session ?: new Session();
        $this->getMbRequest()->setSession($session);

        return $this;
    }
960093
public static function cleanup() {
		if (!isset($_SESSION[Config::$sticky_session_name])) {
			return;
		}

		foreach ($_SESSION[Config::$sticky_session_name] as $key => $variables) {
			if (isset($variables['counter']) and $variables['counter'] < 1) {
				$_SESSION[Config::$sticky_session_name][$key]['counter']++;
				continue;
			}
			unset($_SESSION[Config::$sticky_session_name][$key]);
		}
	}
573107
@Override
    public void dispose(final Session session) {
        if (session != null && session.isConnected()) {
            logger.trace("Disposing of hibernate session.");
            session.close();
        }
    }
341826
public static void close(Session session) {
		if (session != null && session.isConnected()) {
			session.disconnect();
		}
		JschSessionPool.INSTANCE.remove(session);
	}