Save "retain" filter values in session. Retain filters
are those whose handler is defining a retainValueInSession()
function which returns true.
977879
protected function putRetainedFilterValuesInSession()
    {
        collect($this->filterHandlers)
            // Only filters sent which are declared "retained"
            ->filter(function($handler, $attribute) {
                return request()->has("filter_$attribute")
                    && $this->isRetainedFilter($handler, $attribute);
            })
            ->each(function($handler, $attribute) {
                // Array case: we store a coma separated string
                // (to be consistent and only store strings on filter session)
                $value = is_array(request()->get("filter_$attribute"))
                    ? implode(",", request()->get("filter_$attribute"))
                    : request()->get("filter_$attribute");

                if(strlen(trim($value)) === 0) {
                    // No value, we have to unset the retained value
                    session()->forget("_sharp_retained_filter_$attribute");

                } else {
                    session()->put(
                        "_sharp_retained_filter_$attribute",
                        $value
                    );
                }
            });

        session()->save();
    }
799574
def set_session_persistence(self, loadbalancer, val):
        
        val = val.upper()
        uri = "/loadbalancers/%s/sessionpersistence" % utils.get_id(loadbalancer)
        req_body = {"sessionPersistence": {
                "persistenceType": val,
                }}
        resp, body = self.api.method_put(uri, body=req_body)
        return body
516248
private void expireSessions(long timestamp) {
    // Iterate through registered sessions.
    for (RaftSession session : sessions.getSessions(primitiveId)) {
      if (session.isTimedOut(timestamp)) {
        log.debug("Session expired in {} milliseconds: {}", timestamp - session.getLastUpdated(), session);
        session = sessions.removeSession(session.sessionId());
        if (session != null) {
          session.expire();
          service.expire(session.sessionId());
        }
      }
    }
  }
1032030
public void set(ValidationSession session, ProxyField proxyField,
            Object value)
    {
        RuleSessionImpl ruleSession = getRuleSession(session);
        RuleProxyField ruleProxyField = ruleSession.getRuleProxyField(proxyField);
        if (ruleProxyField != null)
        {
            ruleSession.setValue(ruleProxyField, value);
        }
    }
1246742
def store_session(self):
        

        session = []
        for editor in self.list_editors():
            file = editor.file
            ignore_file = True
            if editor.is_untitled and not editor.is_empty():
                file = os.path.join(self.__default_session_directory, file)
                editor.write_file(file)
            elif os.path.dirname(file) == self.__default_session_directory:
                editor.save_file()
            session.append(file)

        for directory in self.list_projects():
            if not os.path.exists(directory):
                continue

            session.append(directory)

        LOGGER.debug("> Storing session :'{0}'.".format(session))
        self.__settings.set_key(self.__settings_section, "session", session)
        return True
486946
private void _saveRedirectValue(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        
        // This request contains a redirect. This condition is in general 
        // triggered by a NavigationHandler. After a redirect all request scope
        // values get lost, so in order to preserve this value we need to
        // pass it between request. One strategy is use a cookie that is never sent
        // to the client. Other alternative is use the session map.
        // See _restoreRedirectValue() for restoring this value.
        HttpServletResponse httpResponse = ExternalContextUtils
                .getHttpServletResponse(externalContext);
        if (httpResponse != null)
        {
            Cookie cookie = _createFlashCookie(FLASH_REDIRECT, "true", externalContext);
            httpResponse.addCookie(cookie);
        }
        else
        {
            externalContext.getSessionMap().put(FLASH_REDIRECT, true);
        }
    }
1037572
public function handleResetFilter()
	{
		/**
		 * Session stuff
		 */
		$this->deleteSessionData('_grid_page');

		if ($this->default_filter_use_on_reset) {
			$this->deleteSessionData('_grid_has_filtered');
		}

		if ($this->default_sort_use_on_reset) {
			$this->deleteSessionData('_grid_has_sorted');
		}

		foreach ($this->getSessionData() as $key => $value) {
			if (!in_array($key, [
				'_grid_per_page',
				'_grid_sort',
				'_grid_page',
				'_grid_has_filtered',
				'_grid_has_sorted',
				'_grid_hidden_columns',
				'_grid_hidden_columns_manipulated',
			], true)) {
				$this->deleteSessionData($key);
			}
		}

		$this->filter = [];

		$this->reloadTheWholeGrid();
	}
233025
private function loadFilterValues()
    {
        $session = new Session();
        $this->filterValues = $session->get($this->getStorageNamespace());
        // Because entities saved into the session are not currently managed,
        // we retrieve the reference id previously set by the storeFilterValues function
        // to load the expected entity
        foreach($this->filters as $datagridFilter) {
            if ($datagridFilter->getType() instanceof DatagridFilterTypeEntity) {
                if (!empty($this->filterValues[$datagridFilter->getName()])) {
                    $filterOptions = $datagridFilter->getOptions();
                    $this->filterValues[$datagridFilter->getName()] = $this->entityManager->getReference(
                        $filterOptions['class'],
                        $this->filterValues[$datagridFilter->getName()]
                    );
                }
            }
        }
    }
371126
def save_session(self, sid, session, namespace=None):
        
        return self.server.save_session(
            sid, session, namespace=namespace or self.namespace)
194046
public static void compareContextState(String filterName, SessionContext context, SessionContext copy) {
        // TODO - only comparing Attributes. Need to compare the messages too.
        Iterator<String> it = context.keySet().iterator();
        String key = it.next();
        while (key != null) {
            if ((!key.equals("routingDebug") && !key.equals("requestDebug"))) {
                Object newValue = context.get(key);
                Object oldValue = copy.get(key);
                if (oldValue == null && newValue != null) {
                    addRoutingDebug(context, "{" + filterName + "} added " + key + "=" + newValue.toString());
                } else if (oldValue != null && newValue != null) {
                    if (!(oldValue.equals(newValue))) {
                        addRoutingDebug(context, "{" +filterName + "} changed " + key + "=" + newValue.toString());
                    }
                }
            }
            if (it.hasNext()) {
                key = it.next();
            } else {
                key = null;
            }
        }

    }
861512
function saveOldSessions() {
    var db = self.store;
    var oldDestroy = db.destroy;
    db.destroy = newDestroy;
    return;

    // rename instead of delete
    function newDestroy(sid, cb) {
      db.get(sid, function(err, session) {
        if (err) return cb(err);
        if (!session) return cb();
        db.set(sid + '_d', session, function(err) {
          if (err) return cb(err);
          oldDestroy.call(db, sid, cb);
        });
      });
    }
  }
792437
def _filter(self, dict, keep):
        
        if not keep:
            return dict

        result = {}
        for key, value in dict.iteritems():
            if key in keep:
                result[key] = value
        return result
518063
def save_value(self, name, value):
        """"""
        session_name = 'list_{}_{}_{}'.format(self.kwargs.get('app'), self.kwargs.get('model'), name)
        self.request.session[session_name] = value
        setattr(self, name, value)
        return value
848312
protected void resetAllValues() {
        logic = new FilterFieldStringData(CommonFilterConstants.LOGIC_FILTER_VAR, CommonFilterConstants.LOGIC_FILTER_VAR_DESC);

        filterVars.clear();
        filterVars.add(logic);
    }
621600
def save_session(self, *args, **kwargs):
        

        # do not send session cookie
        if g.get('stateless_sessions'):
            return

        # send cookie
        return super(BoilerSessionInterface, self).save_session(
            *args,
            **kwargs
        )
1374620
function save(storage, name, value) {
      try {
        var key = propsPrefix + name;
        if (value == null) value = '';
        storage[key] = value;
      } catch (err) {
        console.log('Cannot access local/session storage:', err);
      }
    }
1297058
function savePersistentData()
    {
        $this->HTTP->setSessionVariable( $this->StorageName . $this->MetaDataName, $this->MetaData );
        $this->HTTP->setSessionVariable( $this->StorageName . $this->VariableListName, $this->VariableList );
    }