Set the preference in the user's session.
354402
public function SetToggle() {
      $Session = Gdn::Session();
      if (!$Session->IsValid())
         return;
      
      $ShowAllCategories = GetIncomingValue('ShowAllCategories', '');
      if ($ShowAllCategories != '') {
         $ShowAllCategories = $ShowAllCategories == 'true' ? TRUE : FALSE;
         $ShowAllCategoriesPref = $Session->GetPreference('ShowAllCategories');
         if ($ShowAllCategories != $ShowAllCategoriesPref)
            $Session->SetPreference('ShowAllCategories', $ShowAllCategories);
            
         Redirect('/'.ltrim(Gdn::Request()->Path(), '/'));
      }
   }
518150
private void initializePreferenceButton() {
        Button preferenceButton = findViewById(R.id.preference_button);
        preferenceButton.setOnClickListener(createPreferenceButtonListener());
    }
34435
public void initializeDefaultPreferences() {
		IPreferenceStore store = Activator.getDefault().getPreferenceStore();
		store.setDefault(PreferenceConstants.P_DEFAULT_ROOT_FOLDER, PreferencesUtil.getDefaultRootFolder());
		store.setDefault(PreferenceConstants.P_MAVEN_HOME, PreferencesUtil.getMavenHome());
		store.setDefault(PreferenceConstants.P_GROOVY_MODEL, PreferencesUtil.getCustomGroovyModelImpl());
		store.setDefault(PreferenceConstants.P_ECLIPSE_GOAL, "eclipse:eclipse");
		store.setDefault(PreferenceConstants.P_SFTP_ROOT_FOLDER, PreferencesUtil.getDefaultSftpRootFolder());
		
/*
    static public String getDefaultRootFolder() {
    static public String getMavenHome() {
	static public String getCustomGroovyModelImpl() {
    static public String getDefaultSftpRootFolder() {
 */
	}
1103260
protected function setUser() {
		if (!empty($this->getSiteConfig()['USER_CLASS'])) {
			$className = "{$this->getSiteConfig()['NAMESPACE_APP']}Classes\\Data\\{$this->getSiteConfig()['USER_CLASS']}";
			if (class_exists($className)) {
				$this->setGlobalUser(new $className());
			} else {
				$this->getLogger()->error("Configured User class not found: {$className}");
			}
		} else if (isset($this->getSiteConfig()['USECAS']) && $this->getSiteConfig()['USECAS']) {
			$this->setGlobalUser(new Data\UserCAS($this->getSanitizedInputData(),$this->getDataRepository('Users')));
		} else {
			$this->setGlobalUser(new Data\UserDB());
		}
	}
1186896
def set_user(self, user):
        
        super(Segment, self)._check_ended()
        self.user = user
1040404
def _set_status(self, status, ex=None):
        '''  '''
        self._status = status
        logger.debug("Set status(%s) for %s" % (self._status, self.session_id))
        self.set_done()
        if ex:
            self._exception = ex
131210
protected function setSessionConfig ()
    {
        // 1 WEEK FROM NOW
        $oneWeek        = time() + 60 * 60 * 24 * 7;
        $this->expire   = $this->expire     ?? $oneWeek;
        // '/path' or dir that is using cookies
        $this->path     = $this->path       ?? "/";
        // 'www.mysite.com';
        $this->domain   = $this->domain     ?? NULL;
        // isset($_SERVER['HTTPS']);
        $this->secure   = $this->secure     ?? NULL;
        // JavaScript can't access cookie
        $this->httponly = $this->httponly   ?? TRUE;
        session_set_cookie_params($this->expire, $this->path, $this->domain, $this->secure, $this->httponly);
    }
19420
def session_preparation(self):
        """"""
        self._test_channel_read()
        self.set_base_prompt()
        self.tmsh_mode()
        self.set_base_prompt()
        self.disable_paging(
            command="modify cli preference pager disabled display-threshold 0"
        )
        self.clear_buffer()
        cmd = 'run /util bash -c "stty cols 255"'
        self.set_terminal_width(command=cmd)
688167
public function setPreference(string $setting_name, string $setting_value): UserInterface
    {
        Session::put('_GUEST_' . $setting_name, $setting_value);

        return $this;
    }
334493
def set_user_session(user):
    
    from uliweb import settings, request

    user_fieldname = settings.get_var('AUTH/GET_AUTH_USER_FIELDNAME', 'id')
    share_session = settings.get_var('AUTH/AUTH_SHARE_USER_SESSION', False)
    if isinstance(user, dict):
        user_id = user[user_fieldname]
    else:
        user_id = getattr(user, user_fieldname)

    if share_session:
        cache = functions.get_cache()
        key = get_user_session_key(user_id)
        session_id = cache.get(key, None)
        log.debug('Auth: user session user_id={}, session_id={}, key={}'.format(user_id, session_id, key))
        if not session_id:
            request.session.save()
            log.debug('Auth: set user session mapping userid={}, '
                      'session_id={}, expiry time={}'.format(user_id,
                                                             request.session.key,
                                                             request.session.expiry_time))
            cache.set(key, request.session.key, expire=request.session.expiry_time)
        elif session_id != request.session.key:
            log.debug('Auth: load oldkey={}, key={}'.format(request.session.key, session_id))
            request.session.delete()
            request.session.load(session_id)
    if isinstance(user, dict):
        request.session[_get_auth_key()] = user
    else:
        request.session[_get_auth_key()] = user_id
    request.user = user
241208
def _read_preference_for(self, session):
        
        # Override this operation's read preference with the transaction's.
        if session:
            return session._txn_read_preference() or self.__read_preference
        return self.__read_preference
1019533
def OnWidget(self, event):
        """'"""

        self.choice_dialects.SetValue(len(self.choices['dialects']) - 1)
        event.Skip()
871207
def set_default_option(cls, key, value):
        """"""
        cls._default_options.update(cls._option_schema({key: value}))
100794
def set_options(
        self, time_duration: int = 1, time_reset: int = 2, peak: int = -30
    ) -> None:
        """"""
        self._time_duration = time_duration
        self._time_reset = time_reset
        self._peak = peak
734394
def _set_choices(self, value):
        
        super(LazyChoicesMixin, self)._set_choices(value)
        self.widget.choices = value
915207
def _setsession(self, con=None):
        """"""
        if con is None:
            con = self._con
        if self._setsession_sql:
            cursor = con.cursor()
            for sql in self._setsession_sql:
                cursor.execute(sql)
            cursor.close()
77605
def get_preferences_from_user(self):
        """"""

        dlg = PreferencesDialog(self.main_window)

        change_choice = dlg.ShowModal()

        preferences = {}

        if change_choice == wx.ID_OK:
            for (parameter, _), ctrl in zip(dlg.parameters, dlg.textctrls):
                if isinstance(ctrl, wx.Choice):
                    value = ctrl.GetStringSelection()
                    if value:
                        preferences[parameter] = repr(value)
                else:
                    preferences[parameter] = repr(ctrl.Value)

        dlg.Destroy()

        return preferences