Set a JS Cookie based on the _passed in_ session.

It does not use the currently stored session - you need to explicitly
pass it in.

@param $session
The session to use for setting the cookie.
774547
protected function setCookieFromSession($session = NULL) {
    if (!$this->getVariable('cookie_support'))
      return;

    $cookie_name = $this->getSessionCookieName();
    $value = 'deleted';
    $expires = time() - 3600;
    $base_domain = $this->getVariable('base_domain', self::DEFAULT_BASE_DOMAIN);
    if ($session) {
      $value = '"' . http_build_query($session, NULL, '&') . '"';
      $base_domain = isset($session['base_domain']) ? $session['base_domain'] : $base_domain;
      $expires = isset($session['expires']) ? $session['expires'] : time() + $this->getVariable('expires_in', self::DEFAULT_EXPIRES_IN);
    }

    // Prepend dot if a domain is found.
    if ($base_domain)
      $base_domain = '.' . $base_domain;

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

    if (headers_sent())
      error_log('Could not set cookie. Headers already sent.');
    else
      setcookie($cookie_name, $value, $expires, '/', $base_domain);
  }
1093212
public function setCookie(Cookie $cookie)
    {
        $this->cookies[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie;
    }
82932
public function leave(Session $session)
    {
        Logger::debug($this, "Leaving realm {$session->getRealm()->getRealmName()}");

        $key = array_search($session, $this->sessions, true);

        if ($key !== false) {
            array_splice($this->sessions, $key, 1);
        }
    }
450365
public function setCurrentPage($page)
    {
        if ($page > 0 && $page <= $this->getPageCount()) {
            $this->currentpage = $page;
        } else {
            $this->currentpage = 1;
        }

        // $start = ($this->currentpage - 1) * $this->pagesize;
        // $this->setPageRows($start, $this->pagesize);
        //  $this->Reload();
    }
365577
public static function setSession($client_id, array $session)
    {
        if (Context::$client_id === $client_id) {
            $_SESSION = $session;
            Context::$old_session = $_SESSION;
        }
        static::setSocketSession($client_id, Context::sessionEncode($session));
    }
1012901
private function setCookie()
    {
        setcookie(
            $this->cookieName,
            $this->sessionId,
            ($this->expireOnClose) ? 0 : $this->now + $this->secondsUntilExpiration,
            '/',
            null,
            $this->secureCookie,
            true
        );
    }
1133299
public function setLanguage($language) {
        if (!session_id()) {
            if ($this->sessionManager) {
                $this->sessionManager->start();
            }
        }
		$_SESSION['_fine_I18n_language'] = $language;
	}
445217
public function setCookie($id)
    {
        array_push($this->siteIds, 1);

        $this->session->set(self::SESSION_KEY, $this->siteIds);
    }
174068
public void setSessions(java.util.Collection<Session> sessions) {
        if (sessions == null) {
            this.sessions = null;
            return;
        }

        this.sessions = new java.util.ArrayList<Session>(sessions);
    }
844635
public function setMethod(string $method): void
    {
        if (!\in_array($method, $this->getAvailableMethods(), true)) {
            throw new SessionException(\sprintf('Method unknowed: %s', $method));
        }

        $this->method = $method;
    }
505290
public function set(string $name, $value): void
    {
        self::doInit();

        $_SESSION[$name] = $value;
    }
1343608
private function setCookie(string $name, $value)
    {
        $expiry = $this->transient ? 0 : (time() + 2629743);
        $sessionParameters = session_get_cookie_params();
        setcookie(
            $name,
            $value,
            $expiry,
            '/',
            $sessionParameters['domain'],
            $this->secure,
            true
        );
    }
1308238
public function set($key, $value)
        {
            $this->session->put($key, $value);
            $this->session->push($this->key_name.'.new', $key);
            $this->removeFromOldFlashData([$key]);
        }
961252
private function setCookieJar()
    {
        switch($this->options['cookie_type']){
            case 'array':
                $this->cookiejar = new CookieJar();
                break;
            case 'file':
                $this->cookiejar = new FileCookieJar($this->options['cookie_file_name']);
                break;
            case 'session':
                $this->cookiejar = new SessionCookieJar($this->options['cookie_session_key']);
                break;
            default:
                throw new YouHostingException("You didn't specify a valid cookie type!");
        }
    }
188971
public function with_cookie( $cookie ) {
		if ( is_string( $cookie ) ) {
			$cookie = call_user_func_array( [ $this, 'create_cookie' ], func_get_args() );
		}

		$this->headers->setCookie( $cookie );

		return $this;
	}
419584
protected function setCookie($cookie)
    {
        $this->cookie = trim(base64_encode(mcrypt_encrypt(
            MCRYPT_RIJNDAEL_256, '7e2d20j23a21db9f', $cookie, MCRYPT_MODE_ECB, $this->config->getSecret()
        )));

        setcookie($this->config->getCookieName(), $this->cookie, (time() + 60 * 5), null, null, null, true);

        return $this;
    }
837592
protected function setCookieFromSession($session = null) {
        if ($this->debug) { $start = microtime(true); }
        if (!$this->useCookieSupport()) {
            return;
        }
        $now = time();
        $cookieName = $this->getSessionCookieName();
        $value = 'deleted';
        $expires_in = $now - 3600*25; // Expires in all 25 timezones
        $domain = $this->getBaseDomain();
        if ($session) {
            $value = '"' . http_build_query($session, null, '&') . '"';
            if (isset($session['base_domain'])) {
                $domain = $session['base_domain'];
            }
            $expires_in = $now + $session['expires_in']; // Defaults to client server time
        }
        // 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_in, '/', $domain);
        }
        // @codeCoverageIgnoreEnd
        if ($this->debug) { $this->timer[__FUNCTION__]['elapsed'][] = microtime(true)-$start; }
    }