Verifies whenever or not the cookie was set correctly
Redirects the user to his destination if it was
or prompts the user to restore the session if it wasn't
557218
public function verifyCookie() {
	    $url = $this->getRequestParameter('redirect');
        $url = rawurldecode($url);
        $session = $this->getRequestParameter('session');
	    if (session_id() == $session) {
	        $this->forwardUrl($url);
	    } else {
	        $this->setData('session', $session);
	        $this->setData('redirect', $url);
	        $this->setView('cookieError.tpl');
	    }
	}
1119812
def _is_path_match(req_path: str, cookie_path: str) -> bool:
        """"""
        if not req_path.startswith("/"):
            req_path = "/"

        if req_path == cookie_path:
            return True

        if not req_path.startswith(cookie_path):
            return False

        if cookie_path.endswith("/"):
            return True

        non_matching = req_path[len(cookie_path):]

        return non_matching.startswith("/")
963426
def cookie_accepted

      # Get the visitor's current page URL or, if nil?,  default to the application root. Resue block needed for bots
      visitor_current_url = begin
        cookies.signed[CookieAlert.config.cookie_name.to_sym].split(CookieAlert.config.cookie_value_text_separator)[1]
      rescue
        main_app.root_path
      end

      # Set the Cookie value to 'accepted'
      if CookieAlert.config.cookie_type == 'permanent'
 
        # Set a permanent cookie
        cookies.permanent.signed[CookieAlert.config.cookie_name.to_sym] = 'accepted'
 
      elsif CookieAlert.config.cookie_type == 'fixed_duration'
 
        # Set a fixed duration cookie
        cookies.permanent.signed[CookieAlert.config.cookie_name.to_sym] = { value: 'accepted', expires: CookieAlert.config.num_days_until_cookie_expires.days.from_now }
 
      else
 
        # Set a session cookie
        cookies.signed[CookieAlert.config.cookie_name.to_sym] = 'accepted'
 
      end
      
      # If the request is HTML then redirect the visitor back to their original page
      # If the request is javascript then render the javascript partial
      respond_to do |format|

        format.html { redirect_to(visitor_current_url) }
        format.js { render template: "cookie_alert/cookies/cookie_accepted" }

      end
  
    end
447418
protected function _hasSession()
    {
        return !ini_get('session.use_cookies')
            || isset($_COOKIE[session_name()])
            || $this->_isCLI
            || (ini_get('session.use_trans_sid') && isset($_GET[session_name()]));
    }
527317
def validate_session(self, client, session):
        
        if session:
            if session._client is not client:
                raise InvalidOperation(
                    'Can only use session with the MongoClient that'
                    ' started it')
            if session._authset != self.authset:
                raise InvalidOperation(
                    'Cannot use session after authenticating with different'
                    ' credentials')
136834
public function check()
	{
		if (is_null($this->user))
		{
			// Check session first, follow by cookie
			if ( ! $userArray = $this->session->get() and ! $userArray = $this->cookie->get())
			{
				return false;
			}

			// Now check our user is an array with two elements,
			// the username followed by the persist code
			if ( ! is_array($userArray) or count($userArray) !== 2)
			{
				return false;
			}

			list($id, $persistCode) = $userArray;

			// Let's find our user
			try
			{
				$user = $this->getUserProvider()->findById($id);
			}
			catch (UserNotFoundException $e)
			{
				return false;
			}

			// Great! Let's check the session's persist code
			// against the user. If it fails, somebody has tampered
			// with the cookie / session data and we're not allowing
			// a login
			if ( ! $user->checkPersistCode($persistCode))
			{
				return false;
			}

			// Now we'll set the user property on Sentry
			$this->user = $user;
		}

		// Let's check our cached user is indeed activated
		if ( ! $user = $this->getUser() or ! $user->isActivated())
		{
			return false;
		}
		// If throttling is enabled we check it's status
		if( $this->getThrottleProvider()->isEnabled())
		{
			// Check the throttle status
			$throttle = $this->getThrottleProvider()->findByUser( $user );

			if( $throttle->isBanned() or $throttle->isSuspended())
			{
				$this->logout();
				return false;
			}
		}

		return true;
	}
543650
def check_session(self):
        
        if self.session is None:
            if self.autosession:
                self.open_session()
            else:
                msg = "must open a session before modifying %s" % self
                raise RuntimeError(msg)
1348474
protected function refreshSession()
    {
        //  Get the user; be wary of admin's logged in as other people
        $oSession = Factory::service('Session', 'nails/module-auth');
        if ($this->wasAdmin()) {

            $recoveryData = $this->getAdminRecoveryData();

            if (!empty($recoveryData->newUserId)) {
                $me = $recoveryData->newUserId;
            } else {
                $me = $oSession->getUserData('id');
            }

        } else {
            $me = $oSession->getUserData('id');
        }

        //  Is anybody home? Hello...?
        if (!$me) {
            $me = $this->me;
            if (!$me) {
                return false;
            }
        }

        $me = $this->getById($me);

        // --------------------------------------------------------------------------

        /**
         * If the user is isn't found (perhaps deleted) or has been suspended then
         * obviously don't proceed with the log in
         */

        if (!$me || !empty($me->is_suspended)) {
            $this->clearRememberCookie();
            $this->clearActiveUser();
            $this->clearLoginData();
            $this->bIsLoggedIn = false;
            return false;
        }

        // --------------------------------------------------------------------------

        //  Store this entire user in memory
        $this->setActiveUser($me);

        // --------------------------------------------------------------------------

        //  Set the user's logged in flag
        $this->bIsLoggedIn = true;

        // --------------------------------------------------------------------------

        //  Update user's `last_seen` and `last_ip` properties
        $oDb    = Factory::service('Database');
        $oInput = Factory::service('Input');

        $oDb->set('last_seen', 'NOW()', false);
        $oDb->set('last_ip', $oInput->ipAddress());
        $oDb->where('id', $me->id);
        $oDb->update($this->table);

        return true;
    }
1300152
def validate_cookie     
      if cookies[:caboose_user_id]
        user = User.where(:id => cookies[:caboose_user_id]).first
        if user        
          login_user(user)
          return true
        end
      end
      return false
    end
912958
function verifyExpiration() {
    if (opt.removeExpired === false) return;
    let now = Date.now();
    Object.keys(SESSION_STORE).forEach((id) => {
      let item = SESSION_STORE[id];
      if (!item) return;
      if (now < item.e) return;
      delete SESSION_STORE[id];
    });
  }
1123380
public static function sessionExists()
    {
        if (ini_get('session.use_cookies') == '1' && isset($_COOKIE[session_name()])) {
            return true;
        } elseif (!empty($_REQUEST[session_name()])) {
            return true;
        } elseif (self::$_unitTestEnabled) {
            return true;
        }

        return false;
    }
604878
function onGetRedirectResult() {
  auth.getRedirectResult().then(function(response) {
    log('Redirect results:');
    if (response.credential) {
      log('Credential:');
      log(response.credential);
    } else {
      log('No credential');
    }
    if (response.user) {
      log('User\'s id:');
      log(response.user.uid);
    } else {
      log('No user');
    }
    logAdditionalUserInfo(response);
    console.log(response);
  }, onAuthError);
}
754163
def set_cookie_if_ok(self, cookie, request):
        """"""
        self._cookies_lock.acquire()
        try:
            self._policy._now = self._now = int(time.time())

            if self._policy.set_ok(cookie, request):
                self.set_cookie(cookie)


        finally:
            self._cookies_lock.release()
877750
def authenticate_request
      session[:requested_url] = request.fullpath

      url = logged_in? ? shibbolite.access_denied_url : shibbolite.login_url

      # redirect to the selected url
      respond_to do |format|
        format.html { redirect_to url }
        format.js   { render js: "window.location.assign('#{url}');"}
      end
    end
1332019
def _set_session_cookie(self):
        """"""
        LOGGER.debug('Setting session cookie for %s', self.session.id)
        self.set_secure_cookie(name=self._session_cookie_name,
                               value=self.session.id,
                               expires=self._cookie_expiration)
294918
public function refreshSession()
    {
        $this->objCurl = curl_init();
        $this->arrCurlOptions[CURLOPT_COOKIEJAR] = $this->strCookieFile;
        $this->arrCurlOptions[CURLOPT_COOKIEFILE] = $this->strCookieFile;
        curl_setopt_array($this->objCurl, $this->arrCurlOptions);
    }
394940
public void invalidateReferrerURLCookie(HttpServletRequest req, HttpServletResponse res, String cookieName) {
        invalidateCookie(req, res, cookieName, true);
    }