Store user role in cookie, so it can be used with Javascript

@return void
9992
protected function _storeRoleInCookie() {
        $userRecord = Garp_Auth::getInstance()->getUserData();
        if (!empty($userRecord['role'])) {
            $cookie = new Garp_Store_Cookie('Garp_Auth');
            $cookie->userData = array('role' => $userRecord['role']);
        }
    }
83187
public function expireSessionCookie(): void
    {
        if (ini_get('session.use_cookies')) {
            $params = session_get_cookie_params();
            setcookie(
                $this->getName(),
                '',
                $_SERVER['REQUEST_TIME'] - 42000,
                $params['path'],
                $params['domain'],
                $params['secure'],
                $params['httponly']
            );
        }
    }
514383
public function setCookie()
    {
        $language = current($this->getLanguages());
        if ($language !== Yii::$app->language) {
            $this->cookie->value = Yii::$app->language;
            $this->response->getCookies()->add($this->cookie);
        }
    }
437031
private function setAllowedCookies()
    {
        $allowed = (isset($_COOKIE["gdpr_cookie"]) ? explode(',', $_COOKIE["gdpr_cookie"]) : []);
        foreach ($this->scopeSettings["scopes"] as $scope) {
            if ($scope['required'] == 1) {
                $allowed[] = $scope['scope'];
            }
        }

        $this->allowedCookies = $allowed;
    }
1002762
protected function setUser()
    {
        $objectManager = Bootstrap::$staticObjectManager;
        /** @var \Neos\Flow\Security\Context $securityContext */
        $securityContext = $objectManager->get('Neos\Flow\Security\Context');

        $userContext = array();

        if ($securityContext->isInitialized()) {
            $account = $securityContext->getAccount();
            if ($account !== null) {
                $userContext['username'] = $account->getAccountIdentifier();
            }
        }

        if ($userContext !== array()) {
            $this->client->user_context($userContext);
        }
    }
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!");
        }
    }
905358
public function run()
    {
        if (User::count() == 0) {
            $role = Role::where('name', 'admin')->firstOrFail();

            User::create([
                'name'           => 'Admin',
                'email'          => 'admin@admin.com',
                'password'       => bcrypt('password'),
                'remember_token' => str_random(60),
                'role_id'        => $role->id,
            ]);
        }
    }
1319540
private function setVisitorCookie()
    {
        Yii::$app->response->cookies->add(new Cookie([
            'name' => $this->visitorCookieName,
            'value' => $this->visitor->getPrimaryKey(),
            'expire' => time() + $this->visitorCookieTime,
        ]));
    }
302451
function assignUserToRole( $params )
    {
        $location = $params['location'];
        $roleName = $params['role_name'];

        $node = $this->nodeByUrl( $params );
        if( is_object( $node ) )
        {
            $role = eZRole::fetchByName( $roleName );
            if( is_object( $role ) )
                $role->assignToUser( $node->attribute( 'contentobject_id' ) );
        }
    }
1327098
private function initServerCookie() {
		if(!isset($_COOKIE[self::SERVER_COOKIE]) || $_COOKIE[self::SERVER_COOKIE] != self::SERVER_PROTOCOL) {
			$isSuccess = setcookie(self::SERVER_COOKIE, self::SERVER_PROTOCOL, null, '/');
			if(!$isSuccess) {
				throw new \Exception('Unable to set PHP Console server cookie');
			}
		}
	}
1143494
private function setCookiesFromHeaders()
    {
        $this->cookies = [];

        $headers = $this->getHeaderArray("set-cookie");

        foreach ($headers as $line) {
            $cookie = ResponseCookie::fromHeader($line);
            $this->cookies[$cookie->getName()] = $cookie;
        }
    }
1057427
protected function updateUserRole()
    {
        $this->controlAccess('user_role_edit');

        if ($this->role->update($this->data_role['role_id'], $this->getSubmitted())) {
            $this->redirect('admin/user/role', $this->text('Role has been updated'), 'success');
        }

        $this->redirect('', $this->text('Role has not been updated'), 'warning');
    }
856187
def change_user_role(self):
        

        # Get chosen role_key from user form.
        role_key = self.input['form']['role_options']
        # Assign chosen switch role key to user's last_login_role_key field
        self.current.user.last_login_role_key = role_key
        self.current.user.save()
        auth = AuthBackend(self.current)
        # According to user's new role, user's session set again.
        auth.set_user(self.current.user)
        # Dashboard is reloaded according to user's new role.
        self.current.output['cmd'] = 'reload'
594920
private function loadPrincipalFromRememberMeCookie()
    {
        $hash = cookie('remember_me');
        if ($hash === null) {
            return;
        }

        try {
            list($id, $token) = explode('|', base64_decode($hash));
        }
        catch (Exception $e) {
            $this->deleteRememberMeCookie();
            return;
        }

        /** @var Model $user */
        $model = config('auth.model.class');
        $user  = call_user_func([$model, 'find'], $id);
        //$user = User::find($id);
        if ($user !== null && !empty($token) && $token === $user->getAttribute('remember_token')) {
            $this->setPrincipal($user->getId(), $user->getAttribute('name'), $user->getAttribute('role'));
        }
    }
678291
public static function _init()
	{
		// load the auth config
		\Config::load('ormauth', true);

		// deal with invalid column selections
		if ($columns = \Config::get('ormauth.table_columns', array()) == array('*') or ! is_array($columns))
		{
			\Config::set('ormauth.table_columns', array());
		}

		// setup the remember-me session object if needed
		if (\Config::get('ormauth.remember_me.enabled', false))
		{
			static::$remember_me = \Session::forge(array(
				'driver' => 'cookie',
				'cookie' => array(
					'cookie_name' => \Config::get('ormauth.remember_me.cookie_name', 'rmcookie'),
				),
				'encrypt_cookie' => true,
				'expire_on_close' => false,
				'expiration_time' => \Config::get('ormauth.remember_me.expiration', 86400 * 31),
			));
		}
	}
541494
def save(self, set_cookie, **params):
        """"""
        if set(self.store.items()) ^ set(self.items()):
            value = dict(self.items())
            value = json.dumps(value)
            value = self.encrypt(value)
            if not isinstance(value, str):
                value = value.encode(self.encoding)
            set_cookie(self.key, value, **self.params)
            return True
        return False
969345
protected function start(): void
	{
		// Get the session id from the cookie or generate a new one if it doesn't exist.

		$this->sessionId = $this->request->getCookies()->getSigned($this->options['name'], false);

		if($this->sessionId === false)
		{
			$this->sessionId = $this->generateId();
		}

		// Create a new / update the existing session cookie

		$this->setCookie();

		// Load the session data

		$this->loadData();

		// Create a session token if we don't have one

		if(empty($this->sessionData['mako.token']))
		{
			$this->sessionData['mako.token'] = $this->generateId();
		}

		$this->token = $this->sessionData['mako.token'];
	}