Gets a code for when the user is persisted to a cookie or session which identifies the user.
@return string
971942
public function getPersistCode()
    {
        $block = UserSettings::get('block_persistence', false);

        if ($block || !$this->persist_code) {
            return parent::getPersistCode();
        }

        return $this->persist_code;
    }
293406
public function login() : string {
		$token = bin2hex(random_bytes(64));
		$loginHash = password_hash($token, PASSWORD_BCRYPT);

		$stmt = $this->db->prepare(
			"INSERT INTO sessions (user_id, login_hash, api_hash) " .
			"VALUES (?, ?, NULL) " .
			"ON DUPLICATE KEY UPDATE login_hash=?;"
		);
		$stmt->bind_param("iss",
			$this->user->id, $loginHash, $loginHash);
		$stmt->execute();
		$this->db->commit();

		return $token;
	}
1005723
public function hiddenSid()
    {
        $sSid = $sToken = '';
        if ($this->isSidNeeded()) {
            $sSid = "<input type=\"hidden\" name=\"" . $this->getForcedName() . "\" value=\"" . $this->getId() . "\" />";
        }
        if ($this->getId()) {
            $sToken = "<input type=\"hidden\" name=\"stoken\" value=\"" . $this->getSessionChallengeToken() . "\" />";
        }

        return $sToken . $sSid;
    }
160507
protected function getSidFromRequest()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $sid = null;

        $sForceSidParam = $myConfig->getRequestParameter($this->getForcedName());
        $sSidParam = $myConfig->getRequestParameter($this->getName());

        //forcing sid for SSL<->nonSSL transitions
        if ($sForceSidParam) {
            $sid = $sForceSidParam;
        } elseif ($this->_getSessionUseCookies() && $this->_getCookieSid()) {
            $sid = $this->_getCookieSid();
        } elseif ($sSidParam) {
            $sid = $sSidParam;
        }

        return $sid;
    }
507262
public function getVerifyCode()
    {
        $session = Yii::$app->getSession();
        $session->open();
        $name = $this->getSessionKey();
        return $session[$name];
    }
121482
public function getCookie()
    {
        $request = Request::current();
        $settings = CsrfSettings::singleton();

        if ($request instanceof WebRequest){
            $existingCookie = $request->cookie(self::TOKEN_COOKIE_NAME, false);

            if ($existingCookie){
                $this->currentCookie = $existingCookie;
            }
        }

        if (!$this->currentCookie) {
            $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345689.;,!$%^&*()-=+";
            $cookie = "";
            for ($x = 0; $x < self::TOKEN_COOKIE_LENGTH; $x++) {
                $rand = rand(0, strlen($chars) - 1);
                $char = $chars[$rand];

                if (rand(0, 1) == 1) {
                    $char = strtolower($char);
                }

                $cookie .= $char;
            }

            $this->currentCookie = $cookie;

            HttpResponse::setCookie(self::TOKEN_COOKIE_NAME, $cookie, 0, '/', parse_url($settings->domain, PHP_URL_HOST), false, true);
        }

        return $this->currentCookie;
    }
1328909
public function getUserSession() {
		if (isset($_SESSION['user_'.$this->usernameKey])) {
			$arrUser = array();
			foreach ($_SESSION as $strKey => $strValue)
				if (substr($strKey, 0, 4) == 'user_')
					$arrUser[substr($strKey, 4)] = $strValue;
			return $arrUser;
		}

		return false;
	}
806948
public static function GetUserMode()
    {
        $umode = 'register';
        if (array_key_exists('tw_order_umode', $_SESSION)) {
            $umode = $_SESSION['tw_order_umode'];
        }
        if ('user' != $umode) {
            // check if the user is signed in... if so, we change the mode to user
            $oUser = self::getExtranetUserProvider()->getActiveUser();
            if ($oUser && $oUser->IsLoggedIn()) {
                $umode = 'user';
                TShopStepUserDataV2::SetUserMode($umode);
            }
        }

        return $umode;
    }
1294691
private function getCookieId()
    {
        return $this->trackIfEnabled('cookies', function () {
            return ! is_null($name = $this->getConfig('cookie.name'))
                ? $this->getCookieTracker()->track($this->request->cookie($name))
                : null;
        });
    }
518918
public function getCookieToken()
    {
        // If we have accessed the cookie token this request already.
        if ($this->cookieToken !== null) {
            return $this->cookieToken;
        }

        $name = $this->config->getCookieName();
        $plain = '';
        if (isset($_COOKIE[$name])) {
            $encrypted = $_COOKIE[$name]; // Read encrypted cookie.
            $plain = Encryption::decrypt($encrypted, $this->config->getSecretKey());  // Decrypt cookie.
        }
        $this->cookieToken = $plain; // Don't access cookie again.

        return $plain;
    }
848771
protected function generateCartCookieIdentifier()
    {
        $id = null;

        if (ConfigQuery::read("cart.use_persistent_cookie", 1) == 1) {
            $id = $this->tokenProvider->getToken();
            $this->getSession()->set('cart_use_cookie', $id);
        }

        return $id;
    }
163327
function getUserFromPHPSession() {
		if ($this->user == null) {
            $sid = $this->request->session('usersid', '');
            if ($sid == '') {
                // try with a get key
                $sid = $this->request->get('sessionid', '');
            }
			$this->user = $this->getUserFromSession($sid);
		}
        return $this->user;
    }
136996
public function GetIdentity() {
      if (!is_null($this->UserID))
         return $this->UserID;
         
      if (!$this->_CheckCookie($this->CookieName)) {
         $this->_ClearIdentity();
         return 0;
      }
      
      list($UserID, $Expiration) = $this->GetCookiePayload($this->CookieName);
      
      if (!is_numeric($UserID) || $UserID < -2) // allow for handshake special id
         return 0;

      return $this->UserID = $UserID;
   }
1120353
private function _getUser()
    {
    	// This is likely a duplicate check that could be removed....
        if ( empty($this->_user) ) {
            phpCAS::error(
                'this method should be used only after '.__CLASS__
                .'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()'
            );
        }
        return $this->_user;
    }
527767
public function getCookieStr()
    {
        $cookie = '';
        foreach ($this->getCookies() as $co => $vo) {
            if (strtoupper($vo) != 'EXPIRED') {
                $cookie .= $co . '=' . $vo . ';';
            }
        }
        return $cookie;
    }
597886
public function getProposedSessionId()
    {

        // if no session has already been load, initialize the session manager
        /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $manager */
        $manager = $this->getContext()->search(SessionManagerInterface::IDENTIFIER);

        // if no session manager was found, we don't support sessions
        if ($manager == null) {
            return;
        }

        // if we can't find a requested session name, we try to load the default session cookie
        if ($this->getRequestedSessionName() == null) {
            $this->setRequestedSessionName($manager->getSessionSettings()->getSessionName());
        }

        // load the requested session ID and name
        $sessionName = $this->getRequestedSessionName();
        $id = $this->getRequestedSessionId();

        // try to load session ID from session cookie of request/response
        $cookieFound = null;
        if ($id == null && $this->getResponse()->hasCookie($sessionName)) {
            $cookieFound = $this->getResponse()->getCookie($sessionName);
        } elseif ($id == null && $this->hasCookie($sessionName)) {
            $cookieFound = $this->getCookie($sessionName);
        }

        // check if we can find a cookie
        if (is_array($cookieFound)) {
            // iterate over the cookies and try to find one that is not expired
            foreach ($cookieFound as $cookie) {
                if ($cookie instanceof CookieInterface && $cookie->isExpired() === false) {
                    $this->setRequestedSessionId($id = $cookie->getValue());
                }
            }

        // if we found a single cookie instance
        } elseif ($cookieFound instanceof CookieInterface && $cookieFound->isExpired() === false) {
            $this->setRequestedSessionId($id = $cookieFound->getValue());
        }

        // return the requested session
        return $id;
    }
193916
public function getUid(): string
	{
		$uid = $this->request->getCookie(self::TRACKING_COOKIE);
		if (empty($uid)) {
			$charList = 'a-f0-9';
			$uid = Random::generate(8, $charList);
			$uid .= "-" . Random::generate(4, $charList);
			$uid .= "-5" . Random::generate(3, $charList);
			$uid .= "-" . Random::generate(4, $charList);
			$uid .= "-" . Random::generate(12, $charList);

			$this->response->setCookie(self::TRACKING_COOKIE, $uid, self::TRACKING_EXPIRE);
		}
		return $uid;
	}